Switch
Toggle switches with smooth animations, multiple sizes, and color variants.
1import { Switch } from "@/zeroui/components/switches";23export default function Example() {Sizes
1<Switch size="sm" defaultChecked />2<Switch size="md" defaultChecked />3<Switch size="lg" defaultChecked />With Checkmark Icon
1<SwitchIcon defaultChecked />2<SwitchIcon color="green" defaultChecked />3<SwitchIcon color="violet" />With Label
Airplane mode
Notifications
Dark mode
1<SwitchLabel label="Airplane mode" />2<SwitchLabel label="Notifications" variant="filled" />Theme Toggle (Day/Night)
1<SwitchTheme />2<SwitchTheme defaultChecked />3D Switch
1<Switch3D />2<Switch3D defaultChecked />Neumorphic Switch
1<SwitchNeumorphic />2<SwitchNeumorphic defaultChecked />Disabled State
1<Switch disabled />2<Switch disabled defaultChecked />Installation
npx zeroui@latest add switchProps
| name | type | default | description |
|---|---|---|---|
| checked | boolean | undefined | - |
| defaultChecked | boolean | false | - |
| onChange | (checked: boolean) => void | undefined | - |
| disabled | boolean | false | - |
| size | "sm" | "md" | "lg" | "md" | - |
| color | "blue" | "green" | "violet" | "red" | "orange" | "blue" | - |
| className | string | "" | - |