Toggle Group

A group of toggle buttons where one or multiple can be selected.

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 { ToggleGroup, ToggleGroupItem } from "coss-svelte";

Anatomy

  • ToggleGroup
  • ToggleGroupItem

API Reference

ToggleGroup

A group of toggle buttons where one or multiple can be selected.

Signatures

{ type?: "single"; value?: string; onValueChange?: OnChangeFn<string> }{ type: "multiple"; value?: string[]; onValueChange?: OnChangeFn<string[]> }
PropTypeDefaultDescription
type"single" | "multiple""button"Behavior, selection, or HTML type passed to the underlying control.
bind:valuestring | string[]""Current value for the component. Bind with `bind:value` when supported.
itemsToggleItem[][]Items rendered by the component's built-in fallback composition.
children : Snippet<[]>bind:ref : HTMLElement | null

Inherits from Bits UI ToggleGroup.Root.

ToggleGroupItem

Renders one item inside a toolbar group.

children : Snippet<[]>bind:ref : HTMLElement | null

Inherits from Bits UI ToggleGroup.Item.

Implementation Details

Status
Stable
Foundation
bits
Category
Toggle & Choice
Particles
9