Skip to contentKino
Skip to Content

Toggle group

Toggles joined as a Button group, pressed one at a time or several at once, with one highlight that glides between them.

npx shadcn add https://kinoui.com/r/toggle-group.json
Share on

Examples

Cycle 14

5 issues · ends Friday
LED-482
Invoice totals are off by a cent
PR
LED-479
Export to CSV drops the currency column
TA
LED-475
Saved filters for the invoice list
MC
LED-466
Customer names with accents sort last
KW
LED-461
Upgrade the PDF renderer
AO

One at a time

The default: pressing one releases the other. To keep one always pressed, as a view must be, ignore the empty value pressing the pressed one sends.

Reply to Tomás Alvarez

LED-479 · Export to CSV drops the currency column

The currency column comes back if the export runs per account, not per invoice.

Markdown works too

Several at once

multiple lets any number be pressed. An icon size makes the items square; name each one with aria-label.

Filter issues

Ledger web app · all open issues
Showing 20 of 27 issues

Controlled

Own the value to set it from elsewhere, such as a button that clears every filter.

Vertical

orientation="vertical" stacks the items, with their labels along the start edge.

Installation

npx shadcn@latest add https://kinoui.com/r/toggle-group.json
Files
lib/refs.tslib/reduce-motion.tslib/resize.tslib/swap.tsxcomponents/kino/spinner.tsxcomponents/kino/button.tsxcomponents/kino/toggle.tsxlib/run-progress.tslib/highlight.tscomponents/kino/button-group.tsxcomponents/kino/toggle-group.tsx
Packages
@base-ui/reactclass-variance-authority

New to Kino? Installation covers what your project needs first and the @kino namespace.

API reference

ToggleGroup

PropTypeDefaultDescription
valuestring[]NoneThe pressed items, when you own the state. defaultValue when you don’t.
onValueChange(value: string[]) => voidNoneCalled with the pressed items. Pressing the only pressed one sends [].
multiplebooleanfalseLets any number be pressed at once.
size'sm''default''lg''icon-sm''icon''icon-lg''default'The size of every item, as a Toggle's. An item can set its own.
orientation'horizontal''vertical''horizontal'A row or a column, and which arrow keys move between items.
disabledbooleanfalseDisables every item.

ToggleGroupItem

PropTypeDefaultDescription
valuestringNoneWhat the group reports when it is pressed.
size'sm''default''lg''icon-sm''icon''icon-lg'NoneIts own size, in place of the group's.
disabledbooleanfalseDisables this item alone.

Data attributes

AttributeOnDescription
data-pressedToggleGroupItemPresent while it is pressed.
data-multipleToggleGroupPresent when several can be pressed at once.
data-glidedToggleGroupItemPresent on the item the highlight is under.

Accessibility

  • The group has role="group": name it with aria-label. Each item is a <button> with aria-pressed.
  • Tab reaches the group once; the arrow keys move between items, and Space or Enter presses one.
  • The gliding highlight is decoration: it never takes the pointer, and touch doesn’t show it. With less motion asked for, it moves straight to the next item.
  • Pressed is shown by a fill and by the label’s colour; in forced colours the fill takes the system’s highlight.