Atomx Docs
Components

Switch

A control that toggles a single setting on or off, built on Radix UI's Switch primitive.

Install

npx shadcn@latest add https://atomx.acau.net/r/switch.json

Usage

Use Switch for a single on/off setting that takes effect immediately — typical examples are "Enable notifications" or "Dark mode". For toggles that are submitted as part of a form rather than committed instantly, prefer Checkbox.

Always pair Switch with a Label so the toggle's purpose is announced to screen readers and the entire row is clickable.

Preview

Default

On by default

Disabled

Props

Extends React.ComponentProps<typeof SwitchPrimitive.Root>. All Radix Switch props are forwarded.

PropTypeNotes
checkedbooleanControlled checked state.
defaultCheckedbooleanInitial state for uncontrolled usage.
onCheckedChange(checked: boolean) => voidFired when the user toggles the switch.
disabledbooleanDisables interaction and applies muted styling.
requiredbooleanMarks the underlying input as required for form submission.
namestringName attribute on the underlying form input.