Toggle

A button that switches between two states.

Installation

Install the component package, shared coss-svelte theme, and Bits UI peer.

npm install coss-svelte @coss-svelte/theme bits-ui

Usage

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.

PropTypeDefaultDescription
bind:pressedbooleanfalsePressed state for the toggle. Bind with `bind:pressed`.
children : Snippet<[]>bind:ref : HTMLElement | null

Inherits from Bits UI Toggle.Root.

Implementation Details

Status
Stable
Foundation
bits
Category
Toggle & Choice
Particles
8