On
Checked — blue track, thumb at the end.
Instant on/off toggle — native checkbox with role="switch" and a glass
track. Control and label are vertically centered; add .items-start when
the label wraps.
Live
<label class="switch">
<input
class="switch__input"
type="checkbox"
role="switch"
name="auto"
aria-checked="true"
checked
/>
<span class="switch__track" aria-hidden="true">
<span class="switch__thumb"></span>
</span>
<span class="switch__label">Auto-apply matching roles</span>
</label>
import { Switch } from 'caustica-design/core'
<Switch name="auto" defaultChecked>
Auto-apply matching roles
</Switch>
Checked — blue track, thumb at the end.
Unchecked glass track.
.is-invalid for validation errors.
Native disabled — no press.
role="switch" on the checkbox and keep
aria-checked in sync with checked state.
aria-hidden="true" on the track.
| Class | Description |
|---|---|
.switch |
Root label / wrapper. |
.switch__input |
Native checkbox with role="switch". |
.switch__track |
Glass pill track. |
.switch__thumb |
Sliding knob inside the track. |
.switch__label |
Visible label text. |
.is-invalid |
Error border / ring on root or input. |
From src/core/Switch.tsx — extends native
InputHTMLAttributes<HTMLInputElement> (minus type /
role). Syncs aria-checked for controlled and uncontrolled
usage.
| Prop | Type | Default | Description |
|---|---|---|---|
invalid |
boolean |
false |
Applies .is-invalid and aria-invalid. |
children |
ReactNode |
— | When set, wraps in a <label> with label text. |
checked / defaultChecked |
boolean |
— | Controlled or uncontrolled on state. |
onChange |
native | — | Fires on toggle; uncontrolled state updates internally. |
disabled |
boolean |
— | Native disabled state. |
className |
string |
— | Merged onto the root wrapper. |