Switch: Disabled and read-only
readOnly keeps the value visible and focusable but won't change it.
This adds the example as components/examples/switch/states.tsx, together with the Switch component and the HextaUI theme tokens it needs.
pnpm dlx shadcn@latest add https://hextaui.com/r/switch-states.jsonTo add only the component, follow the Switch installation.
Props in this example
The Switch props this example sets, from the API reference.
| Prop | Type | Default |
|---|---|---|
defaultChecked | boolean | false |
disabled | boolean | false |
readOnly | boolean | false |
Every prop is in the Switch API reference.
See them all, with keyboard support and accessibility notes, on the Switch page.
- MotionThe easing curves, durations and reduced-motion check every component animates with, plus hooks for size morphs and sliding highlights.
- SpinnerA loading indicator with Apple-style ticks or a breathing ring that can wait before showing and stay long enough not to flicker.
- CalendarA date grid for single, range and multiple selection, with sliding months, range previews and touch-sized days.
- CheckboxA checkbox whose check draws in, with indeterminate parents, groups and labels that share its hover.
- ComboboxA filterable select with chips, groups and async results, in a popup that resizes as you type.
- Date pickerA button that opens a calendar in a popover, or a bottom sheet on phones, for single dates and ranges.