# Switch

> Toggle switch for binary on/off choices in forms and settings.

## Playground

An interactive playground for Switch is embedded above. Open the canonical story on Storybook: [https://storybook.laioutr.cloud/?path=/story/ui-kit-atoms-switch--small](https://storybook.laioutr.cloud/?path=/story/ui-kit-atoms-switch--small)

## Overview

Switch is a binary on/off toggle for forms, settings, and inline preferences. Wrap it in `<LField>` to pick up shared `disabled`, `required`, and error state without prop-drilling. Pair `invalid` with `Field`'s `errorMessage` for accessible error styling.

## Key Business & UX Benefits

- Clear on/off affordance signals that a change applies immediately, which is what users expect for preferences and notification settings.
- Field integration covers required, disabled, and error states without extra wiring, so toggles in checkout (gift wrap, paper-free billing) stay accessible.
- Consistent sizing (s/m) and motion make every Switch on the site feel like the same control, which reduces the learning curve across account, settings, and forms.

<tip>

Pro-Tip from Larry: Use Switch for state that takes effect immediately (a setting). For confirm-then-apply choices in a form, reach for Checkbox.

</tip>

### Different Sizes

#### Example: Switch Medium

Live preview: [https://storybook.laioutr.cloud/?path=/story/ui-kit-atoms-switch--medium](https://storybook.laioutr.cloud/?path=/story/ui-kit-atoms-switch--medium)

```vue-template
<LSwitch v-model="enabled" size="m" />
```

### Checked State

#### Example: Switch checked

Live preview: [https://storybook.laioutr.cloud/?path=/story/ui-kit-atoms-switch--checked](https://storybook.laioutr.cloud/?path=/story/ui-kit-atoms-switch--checked)

```vue-template
<LSwitch v-model="enabled" />
```

### Disabled State

#### Example: Switch Unchecked Disabled

Live preview: [https://storybook.laioutr.cloud/?path=/story/ui-kit-atoms-switch--disabled](https://storybook.laioutr.cloud/?path=/story/ui-kit-atoms-switch--disabled)

```vue-template
<LSwitch v-model="enabled" disabled />
```

#### Example: Switch Checked Disabled

Live preview: [https://storybook.laioutr.cloud/?path=/story/ui-kit-atoms-switch--disabled-checked](https://storybook.laioutr.cloud/?path=/story/ui-kit-atoms-switch--disabled-checked)

```vue-template
<LSwitch v-model="enabled" disabled />
```

## Feature List

<features :items="["Two sizes ('s', 'm') keep the toggle in proportion with form, settings, and inline preference rows","Boolean v-model with checked/unchecked plus disabled and `:focus-visible` states, so the control fits accessibility audits without extra wiring","Inherits `<LField>` `disabled`, `required`, and `invalid` state so wrapped switches pick up form chrome automatically","Used internally by `HighlightToggle`, so promotional toggles stay consistent with regular preference switches","Plain semantic toggle: pairs cleanly with Label for click-to-toggle association on the entire row"]">



</features>

## API Reference

#### Props

```json
{"type":"object","properties":{"defaultChecked":{"type":"boolean","default":false},"disabled":{"type":"boolean","default":false},"id":{"type":"string","default":"void 0"},"name":{"type":"string","default":"void 0"},"value":{"type":"string","default":"void 0"},"required":{"type":"boolean","default":false},"invalid":{"type":"boolean","default":false},"size":{"enum":["s","m"],"type":"string","default":"m"},"modelValue":{"type":"boolean"}}}
```

#### Events

```json
[{"name":"update:modelValue","description":"","tags":[],"type":"[value: boolean | undefined]","signature":"(event: \"update:modelValue\", value: boolean | undefined): void","schema":[{"kind":"enum","type":"boolean | undefined","schema":["undefined","false","true"]}]}]
```
