Skip to content
Zuno UI
Explore components
EXPLORE
Actions
Forms
Layout
Navigation
Data display
Feedback
Overlays
RESOURCES
Components/Switch

Switch

A clear on/off state with an associated label; not a blanket replacement for checkbox.

Base UI reference ↗

Installation

Run it from the root of a project already set up with zunoui init.

npx zunoui@latest add switch

Dependencies

What add switch installs alongside the component. The CLI skips any you already have in a compatible version.

ZUNO registry

  • @zuno/utils

npm

Examples

1 examples · 1 component
switch

On, off and disabled

The thumb and surface communicate the state.

API reference

Keeps the props, events and refs of the matching Base UI primitive, plus ZUNO's styles.

PropTypeDefault
checked / defaultChecked

Controlled or initial state.

boolean—
onCheckedChange

Called when the state changes.

(checked: boolean) => void—
disabled

Disables the control.

booleanfalse

States

The states that apply to this component and their visual treatment.

StateTreatment
OffThumb on the left over a neutral surface.
Onchecked moves the thumb and changes the surface.
Focus visible2 px ring outline with the keyboard.
Disableddisabled removes interaction and focus.

Accessibility

Use Switch for settings that take effect immediately; for options confirmed when a form is submitted, prefer Checkbox.

Associate it with a label; the thumb position and color communicate the state.