Actions Core Stable

ToggleGroup

A segmented row of toggle buttons with roving-tabindex keyboard navigation and single or multiple selection.

Preview

Installation

pnpm add fancy-ui-svelte
import { ToggleGroup } from 'fancy-ui-svelte'

Usage

svelte
<script lang="ts">
  import { ToggleGroup } from 'fancy-ui-svelte';
</script>

<ToggleGroup />

Examples

Basic Usage

Single Selection

Activating the active item again clears it.

Multiple Selection

Independent on/off marks with type="multiple".

Vertical

A vertical rail — both arrow-key pairs still work.

Disabled Items

One item unavailable; the keyboard model skips it.

Props

PropTypeDefaultDescription
type "single" | "multiple""single"Whether one item can be active at a time, or several.
value string | string[]""The active value(s), bindable — a string when type="single", an array of strings when type="multiple".
onValueChange (value: string | string[]) => void-Called with the new value, shaped to match `type`, whenever the selection changes.
disabled booleanfalseDisables every item in the group.
size "sm" | "md" | "lg""md"Sizes every item.
orientation "horizontal" | "vertical""horizontal"The rail's stacking axis; both arrow-key pairs work either way.
label string-Accessible name for the group.
class string-Additional CSS classes, merged onto the root.
ref HTMLDivElement | nullnullBindable reference to the root element.
ToggleGroupItem.value *string-The item's value — what gets added to or removed from the group's selection.
ToggleGroupItem.disabled booleanfalseDisables just this item, independent of the group's own `disabled`.
ToggleGroupItem.label string-Accessible name for icon-only content on this item. Also the text fallback.
ToggleGroupItem.class string-Additional CSS classes, merged onto the item's button.
ToggleGroupItem.ref HTMLButtonElement | nullnullBindable reference to the item's button element.

Slots

SlotDescription
childrenThe ToggleGroup's content — the ToggleGroupItems.
ToggleGroupItem.childrenThe item's content, typically a glyph or a short label.