Switch — dir/ui
A two-state control for turning a setting on or off.
# Switch
A two-state control for turning a setting on or off.
## Install
```sh
npx shadcn@4.21.0 add lr-run/dir-ui/switch#v0.1.2
```
[Registry item with source and dependencies](https://github.com/lr-run/dir-ui/blob/v0.1.2/registry.json)
Requires React 19, Tailwind CSS 4 and shadcn initialized with Base UI. Registry target placeholders resolve through components.json: @ui, @components, @hooks and @lib. Imports below use the conventional @/ prefix for illustration; the CLI rewrites them to your configured aliases. Shared components are installed once through registryDependencies. Theme CSS is imported by the UI modules. Existing files are never forcibly overwritten; review CLI conflicts before accepting changes. No Dir runtime is required.
## Switch
```tsx
import { Switch } from '@base-ui/react/switch'
```
| Prop | Type | Default / required | Notes |
| --- | --- | --- | --- |
| Root.checked / Root.defaultChecked | boolean | false | |
| Root.onCheckedChange | (checked: boolean, details) => void | — | |
| Root.disabled / Root.required | boolean | false | |
| Root.name / Root.value | string | — | |
| Root.aria-label | string | — | |
| Root.className / Thumb.className | string | — | |
Uses Base UI Switch.Root and Switch.Thumb.