Switch

Markdown

An on/off setting with a label.

Used in Settings and billing.

Use it for
A setting that applies as soon as it is flipped.
Not for
Choices that only apply when a form is submitted. Try Checkbox.

Switch preview

Loading example…

Installation

npm install @stackunseen/ui
import { Switch } from '@stackunseen/ui';
Styles: @stackunseen/ui/styles.css

Usage and props

Use for an on/off setting, such as email notifications. Give it a label through Field or a native label, and keep the label the same in both states. Keep the label the same whether it’s on or off. Whether it’s on comes from your app, not from a guess about what the server did.

checkedboolean (optional)
The controlled on/off state.
onCheckedChange(checked: boolean) => void (optional)
Receives the next state. Your application decides when to save the setting.
namestring (optional)
The form-data key. The switch uses a native checkbox input.
disabledboolean (optional)
Prevents changes and excludes the switch from native form submission.
How state and callbacks work
All props

Loading…

For your coding agent

Give the agent this page instead of a screenshot. The prompt wraps the page with the install and import lines and the rule that your server, not a click, completes an action.

Contract
checked? · onCheckedChange? · native input props/ref
Keeps honest
Keep the label the same whether it’s on or off. Whether it’s on comes from your app, not from a guess about what the server did.
MCP
read_component "Switch" on the docs endpoint
Open the Markdown file

Keyboard and customization

Keyboard

Tab focuses the switch; Space toggles it. Disabled switches leave the tab order.

Customization

Change shared colors, spacing, corners and icons with the theme. Use the component's supported props to adapt its content and layout. Customization guide and Theme Studio