Toggle
A button that switches between two states.
<script lang="ts">
import { Toggle } from "coss-svelte";
</script>
<Toggle>Toggle</Toggle>
Installation
Install the component package, shared coss-svelte theme, and Bits UI peer.
npm install coss-svelte @coss-svelte/theme bits-uiUsage
Import the Svelte component exports directly from the package.
import { Toggle } from "coss-svelte";Anatomy
Toggle exposes a single component export for the current implementation.
API Reference
Toggle
A button that switches between two states.
| Prop | Type | Default | Description |
|---|---|---|---|
bind:pressed | boolean | false | Pressed state for the toggle. Bind with `bind:pressed`. |
children : Snippet<[]>bind:ref : HTMLElement | nullInherits from Bits UI Toggle.Root.
Implementation Details
- Status
- Stable
- Foundation
- bits
- Category
- Toggle & Choice
- Particles
- 8