Switch
<Switch>TailwindCSS ModulesA toggle switch for immediately turning a setting on or off.
npx coloxo add switch --style coloxo-cssimport { Switch } from '@coloxo/ui';Design Tokens:
1. Variant Matrix
Switches clearly indicate on/off state through color and position.
| Default | Checked | Disabled | |
|---|---|---|---|
| States | Applies from next cycle | Send me daily reports |
2. Interactive Props Configurator
Checked State
Show Description
Disabled State
Applies from next cycle
<Switch label="Enable overtime" description="Applies from next cycle"/>3. Dark theme
Switches adapt their track and thumb colors for optimal contrast in dark mode.
Applies from next cycle
Send me daily reports
4. Enterprise layout compositions
Switches are often grouped in settings pages to control application preferences.
Notification Settings
Receive updates about new products.
Critical notifications about your account.
A summary of your weekly activity.
Accessibility
Built on Radix Switch, ensuring `role="switch"` and full keyboard support (Space / Enter to toggle).
The label and description texts are automatically linked to the switch control so screen readers announce them properly.
Props
| Name | Type | Default | Description |
|---|---|---|---|
| label | ReactNode | — | Switch label text. |
| description | ReactNode | — | Helper text below the label. |
| checked | boolean | — | Controlled state. |
| defaultChecked | boolean | — | Uncontrolled initial state. |
| onCheckedChange | (checked: boolean) => void | — | State change handler. |
| disabled | boolean | — | Disables the switch. |