Switch

<Switch>TailwindCSS Modules

A toggle switch for immediately turning a setting on or off.

InstallationColoxo CLI
npx coloxo add switch --style coloxo-css
ES Module ImportPlayground / npm package
import { Switch } from '@coloxo/ui';

Design Tokens:

--cx-brand-600: #2348FF--cx-slate-200: #E2E8F0--cx-bg-primary: #FFFFFF--cx-radius-full: 9999pxtransition: 150ms

1. Variant Matrix

Switches clearly indicate on/off state through color and position.

DefaultCheckedDisabled
States

Applies from next cycle

Send me daily reports

2. Interactive Props Configurator

Checked State

Show Description

Disabled State

Visual Render Canvas

Applies from next cycle

tsx
<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

Radix UI Primitives

Built on Radix Switch, ensuring `role="switch"` and full keyboard support (Space / Enter to toggle).

Label Association

The label and description texts are automatically linked to the switch control so screen readers announce them properly.

Props

NameTypeDefaultDescription
labelReactNode—Switch label text.
descriptionReactNode—Helper text below the label.
checkedboolean—Controlled state.
defaultCheckedboolean—Uncontrolled initial state.
onCheckedChange(checked: boolean) => void—State change handler.
disabledboolean—Disables the switch.