6.9k

Switch

Previous Next

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

Docs API Reference
<script lang="ts">
  import { Label } from "$lib/components/ui/label/index.js";
  import { Switch } from "$lib/components/ui/switch/index.js";
</script>
 
<div class="flex items-center space-x-2">
  <Switch id="airplane-mode" />
  <Label for="airplane-mode">Airplane Mode</Label>
</div>

Installation

pnpm dlx shadcn-svelte@latest add switch

Usage

<script lang="ts">
  import { Switch } from "$lib/components/ui/switch/index.js";
</script>
<Switch />