Switch
A control for toggling between checked and unchecked states.
$
Registry itembunx shadcn@latest add @nx-ui/switchInstalls withutils
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.
| Prop | Type | Default | Description |
|---|---|---|---|
size | "sm" | "default" | "default" | — |
…extends SwitchPrimitive.Root.Props