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.

PropNotes
checked / defaultCheckedControlled vs uncontrolled.
onCheckedChange(checked: boolean) => void
disabledDisables the control.
name / valueFor form submission.

On this page