Toggle

A two-state button that can be on or off.

<script lang="ts">
  import { Toggle } from "$lib/components/ui/toggle";
</script>
 
<Toggle aria-label="Toggle bold">
  <!-- heroicons-ish: bold -->
  <svg
    viewBox="0 0 24 24"
    fill="none"
    stroke="currentColor"
    stroke-width="2.2"
    stroke-linecap="round"
    stroke-linejoin="round"
    aria-hidden="true"
  >
    <path d="M6 4h7a4 4 0 0 1 0 8H6zM6 12h8a4 4 0 0 1 0 8H6z" />
  </svg>
  Bold
</Toggle>

Installation

npx lily-svelte@latest add toggle

Usage

<script lang="ts">
	import { Toggle } from '$lib/components/ui/toggle';
 
	let pressed = $state(false);
</script>
 
<Toggle bind:pressed>Bold</Toggle>

Built by levish. The source code is available on GitHub.

Quiet by design.