SwitchCard
Toggleable switch card
SwitchCard
import SwitchCard from "@intility/bifrost-react/SwitchCard";SwitchCard
Go to top
For convenience, <SwitchCard> is provided as an alias for
<CheckboxCard type="switch">. Otherwise, it functions
exactly the same as <CheckboxCard>.
Basic usage
<SwitchCard label="Switch card"> Users often expect checkboxes to be a part of a form with a submit button, while switches are usually expected to be automatically 'saved'. </SwitchCard>
See <CheckboxCard> for more examples.
Sandbox
You can bind a SwitchCard to a boolean state using the checked prop and update
your state every time the onChange event is triggered.
import { useState } from "react"; import SwitchCard from "@intility/bifrost-react/SwitchCard"; export default function SwitchCardDemo() { const [selected, setSelected] = useState(true); return ( <div className="bf-page-padding"> <SwitchCard label="Switch card" checked={selected} onChange={() => setSelected(!selected)} > Users often expect checkboxes to be a part of a form with a submit button, while switches are usually expected to be automatically 'saved'. </SwitchCard> <p>Current state: {selected.toString()}</p> </div> ); }