Switch is used to select one or more options from a list.
Switch
import { Switch } from "@dreamy-ui/react";
<Switch> Default </Switch>
Change the color scheme of the Switch.
<Switch scheme="primary" defaultChecked>Primary</Switch> <Switch scheme="secondary" defaultChecked>Secondary</Switch> <Switch scheme="success" defaultChecked>Success</Switch> <Switch scheme="warning" defaultChecked>Warning</Switch> <Switch scheme="error" defaultChecked>Error</Switch> <Switch scheme="info" defaultChecked>Info</Switch> <Switch scheme="none" defaultChecked>None</Switch>
Change the Switch size.
<Switch size="sm">Sm</Switch> <Switch size="md">Md</Switch> <Switch size="lg">Lg</Switch>
Use isChecked and onChange, onChangeValue to control the checkbox.
isChecked
onChange
onChangeValue
Selected: false
export function ControlledSwitch() { const [isChecked, setIsChecked] = useState(false); return ( <> <Text>Selected: {isChecked ? "true" : "false"}</Text> <Switch isChecked={isChecked} onChangeValue={setIsChecked} > Controlled </Switch> </> ); }