# Switch

> A labelled on/off toggle switch.

- Category: [Inputs & forms](https://tarve.dev/docs.md#inputs)
- Import: `import { Switch } from "@tarve/core";`
- Props type: `SwitchProps`
- Source: [packages/core/src/controls.ts:39](https://github.com/omarcosr/tarve/blob/main/packages/core/src/controls.ts#L39)

## Usage

```tsx title="Switch.tsx"
import { Switch } from "@tarve/core";

let airplane = false;

<Switch
  label="Airplane mode"
  checked={airplane}
  onCheckedChange={(checked) => {
    airplane = checked;
  }}
/>
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `checked` (required) | `boolean` | — |  |
| `label` (required) | `string` | — |  |
| `disabled` | `boolean` | — |  |
| `glass` | `GlassProp` | — | The iOS 26 switch: a wide track (green, or the glass's tint, when on) under a glass knob. |
| `onCheckedChange` | `(checked: boolean) => void` | — |  |

## Common props

Shared by every component (descriptions: https://tarve.dev/docs.md#common-props): `children`, `class`, `className`, `highlight`, `id`, `key`, `motionFrom`, `onHighlight`, `onPaste`, `onPointerLeave`, `onPointerMove`, `onSize`, `onTransitionEnd`, `rovingGroup`, `style`.

## Types

```ts title="GlassProp"
type GlassProp = boolean | GlassVariant | GlassOptions;
```

Previous: [Checkbox](https://tarve.dev/docs/components/Checkbox.md) · Next: [RadioGroup](https://tarve.dev/docs/components/RadioGroup.md)

---

Tarve v0.13.8 · HTML version: https://tarve.dev/docs/components/Switch · Index for agents: https://tarve.dev/llms.txt
