# Switch: Disabled and read-only

> `readOnly` keeps the value visible and focusable but won't change it.

Example: https://hextaui.com/docs/switch/examples/states
Component docs: https://hextaui.com/docs/switch.md

## Add this example

```bash
npx shadcn@latest add https://hextaui.com/r/switch-states.json
```

This adds `components/examples/switch/states.tsx` with the Switch component and the HextaUI theme tokens.

## Source

```tsx title="components/examples/switch/states.tsx"
import { Switch } from "@/components/ui/switch"

export function SwitchStates() {
  return (
    <div className="flex flex-col gap-4 text-sm">
      <label className="flex items-center gap-3">
        <Switch disabled />
        Disabled
      </label>
      <label className="flex items-center gap-3">
        <Switch disabled defaultChecked />
        Disabled and on
      </label>
      <label className="flex items-center gap-3">
        <Switch readOnly defaultChecked />
        Read-only (managed by your admin)
      </label>
    </div>
  )
}
```

## Props in this example

### Switch

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `defaultChecked` | `boolean` | `false` |  |
| `disabled` | `boolean` | `false` |  |
| `readOnly` | `boolean` | `false` |  |

## More Switch examples

- [iOS](https://hextaui.com/docs/switch/examples/ios.md)
- [Saving](https://hextaui.com/docs/switch/examples/async.md)
- [On and off marks](https://hextaui.com/docs/switch/examples/icons.md)
- [Sizes](https://hextaui.com/docs/switch/examples/sizes.md)
- [In a field](https://hextaui.com/docs/switch/examples/field.md)
- [Controlled](https://hextaui.com/docs/switch/examples/controlled.md)
- [Right to left](https://hextaui.com/docs/switch/examples/rtl.md)
