# Switch (https://www.librechat.ai/docs/development/components/switch)

Use `Switch` for a setting that takes effect as soon as it changes. For an option that is applied when a form is submitted, use a checkbox instead.

<ComponentPreview example="switch/default" title="Switch with a label" />

## Props

| Prop | Type | Description |
| --- | --- | --- |
| `checked` | `boolean` | The controlled state. |
| `onCheckedChange` | `(checked: boolean) => void` | Called when the user toggles the switch. |
| `defaultChecked` | `boolean` | The initial state when uncontrolled. |
| `disabled` | `boolean` | Blocks toggling. |
| `aria-label` or `aria-labelledby` | `string` | Required: exactly one names the switch. |

## Accessibility

The switch exposes the `switch` role with its checked state, and its type requires an accessible name.

| Key | Action |
| --- | --- |
| <kbd>Space</kbd> or <kbd>Enter</kbd> | Toggles the switch |
