Switch
A control that allows the user to toggle between checked and not checked.
Installation
Copy the following code into your app directory.
Command
Command
Manual
Manual
uv
Anatomy
Use the following composition to build a Switch component.
Examples
Description
A standard switch layout featuring a secondary descriptive text block nested alongside the core field.label and switch.root within a vertical field.root layout.
Focus is shared across devices, and turns off when you leave the app.
Choice Card
Card-style selection where field.label wraps the entire field.root layout pattern to create a fully clickable target container.
Disabled
Pass the disabled=True prop directly to the switch.root component to deactivate user input. Pass the data_disabled="true" attribute to the field.root layout component for contextual styling.
Invalid
Pass the aria_invalid="true" prop to the switch.root component to explicitly communicate an unfulfilled state. Pass the data_invalid="true" attribute to the field.root container layout to trigger error typography theme changes automatically.
You must accept the terms and conditions to continue.
Size
Use the size property on switch.root to scale the toggle boundaries down to "sm" or return to "default". Stack components smoothly inside a unified layout using a field.group block.