Switch

A control for toggling between checked and unchecked states.

$bunx shadcn@latest add @nx-ui/switch
Registry item
Installs withutils
Used byisochrone-toollistings-filterssettings

Basic

Pair a Switch with a Label using a matching id. Clicking the label toggles the control.

Sizes

Default and small.

Controlled

Drive `checked` and `onCheckedChange` yourself to react to the toggle.

States

Disabled dims and blocks interaction; aria-invalid draws the destructive ring for validation errors.

Composition: site alert preferences

Switches inside Field/FieldLabel rows, used as a notification preferences panel for a composting site's alert feed.

API reference

Exported parts and their props, extracted from the component source.

PropTypeDefaultDescription
size"sm" | "default""default"

…extends SwitchPrimitive.Root.Props