Switch
A toggle control that switches between on and off states. Ideal for settings, preferences, and feature toggles. Built on Radix UI Switch.
Preview
Default
Settings Group
Receive booking updates
Get travel deals and offers
Use dark theme
Disabled
Usage
tsx
import { Switch } from "zostel-ui";
import { Label } from "zostel-ui";
<div className="flex items-center gap-2">
<Switch id="notifications" />
<Label htmlFor="notifications">Enable notifications</Label>
</div>
{/* Controlled */}
<Switch
checked={isEnabled}
onCheckedChange={setIsEnabled}
/>Props
| Prop | Type | Default | Description |
|---|---|---|---|
checked | boolean | false | The controlled checked state of the switch. |
defaultChecked | boolean | false | The default checked state when uncontrolled. |
onCheckedChange | (checked: boolean) => void | — | Called when the checked state changes. |
disabled | boolean | false | Disables the switch. |
className | string | "" | Additional CSS classes to apply. |
checkedType:
booleanDefault: false
The controlled checked state of the switch.
defaultCheckedType:
booleanDefault: false
The default checked state when uncontrolled.
onCheckedChangeType:
(checked: boolean) => voidDefault: —
Called when the checked state changes.
disabledType:
booleanDefault: false
Disables the switch.
classNameType:
stringDefault: ""
Additional CSS classes to apply.