SwitchCard
Toggleable switch card
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
TSX
<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.
Inactive state
Use state="inactive" for a focusable, tooltip-friendly replacement for
disabled. The card chrome stays at full opacity; only the switch icon dims.
See <CheckboxCard> for the full pattern.
TSX
<SwitchCard state="inactive" label="Inactive switch card">...</SwitchCard>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> ); }