Skip to content

Switch ​

A control that allows the user to toggle between checked and not checked.

Examples ​

Default ​

vue
<script setup>
import { Switch, Label } from '@empathyds/vue'
</script>

<div class="flex items-center space-x-2">
  <Switch id="airplane-mode" />
  <Label for="airplane-mode">Airplane Mode</Label>
</div>

Props ​

Switch ​

PropTypeDefaultDescription
checkedboolean-The controlled checked state of the switch.
defaultCheckedbooleanfalseThe checked state of the switch when it is initially rendered.
disabledbooleanfalseWhether the switch is disabled.
requiredbooleanfalseWhether the switch is required.
namestring-The name of the switch.
valuestring'on'The value of the switch.
idstring-The id of the switch.

Events ​

Switch ​

EventPayloadDescription
update:checkedbooleanEvent handler called when the checked state of the switch changes.

Slots ​

Switch ​

SlotDescription
thumbThe thumb content.