Switch
Toggle control for switching between two states. Built on the Radix UI Switch primitive.
<Switch defaultChecked aria-label="Example switch" />Usage
import { Switch } from "@reva/ui";<Switch defaultChecked />Examples
With label
<HStack align="center" gap={2}> <Switch id="airplane" /> <Label htmlFor="airplane">Airplane mode</Label></HStack>Disabled
<HStack align="center" gap={2}> <Switch disabled id="sw-dis" /> <Label className="opacity-70" htmlFor="sw-dis">Disabled</Label></HStack>Props
Switch forwards props to Radix Switch (SwitchPrimitive.Root). See the Radix UI Switch documentation.
| Prop | Notes |
|---|---|
checked / defaultChecked | Controlled vs uncontrolled. |
onCheckedChange | (checked: boolean) => void |
disabled | Disables the control. |
name / value | For form submission. |