Skip to main content

Toggle Group

A single or multi-select group of toggles with a spring-gliding active pill, a shared sliding hover highlight, and keyboard navigation.

active=center

Customize

SizeDefault
Spacing0
Speed1

Installation

npx shadcn@latest add @kinetic/toggle-group

Usage

Wrap ToggleGroupItem elements in a ToggleGroup. Each item needs a unique value.

import { ToggleGroup, ToggleGroupItem } from "@/components/kinetic/ui/toggle-group";

export function AlignmentGroup() {
  return (
    <ToggleGroup type="single" defaultValue="left" aria-label="Text alignment">
      <ToggleGroupItem value="left">Left</ToggleGroupItem>
      <ToggleGroupItem value="center">Center</ToggleGroupItem>
      <ToggleGroupItem value="right">Right</ToggleGroupItem>
    </ToggleGroup>
  );
}

Single selection

With type="single" (the default), value and defaultValue are strings and onValueChange receives the selected value. Pressing the selected item again clears the selection and onValueChange receives an empty string. The gliding active pill is rendered in this mode.

const [value, setValue] = useState("left");

<ToggleGroup type="single" value={value} onValueChange={setValue}>
  <ToggleGroupItem value="left">Left</ToggleGroupItem>
  <ToggleGroupItem value="right">Right</ToggleGroupItem>
</ToggleGroup>

Multiple selection

With type="multiple", value and defaultValue are arrays of strings and onValueChange receives the full list.

<ToggleGroup type="multiple" defaultValue={["bold"]} aria-label="Text style">
  <ToggleGroupItem value="bold">Bold</ToggleGroupItem>
  <ToggleGroupItem value="italic">Italic</ToggleGroupItem>
  <ToggleGroupItem value="underline">Underline</ToggleGroupItem>
</ToggleGroup>

Variants and sizes

Choose variant as default or outline, and size as sm, default, or lg. The default variant is outline. Use spacing (in 4px steps, default 0) to separate the items instead of joining them.

<ToggleGroup variant="default" size="sm" spacing={4}>
  <ToggleGroupItem value="grid">Grid</ToggleGroupItem>
  <ToggleGroupItem value="list">List</ToggleGroupItem>
</ToggleGroup>

Orientation

Set orientation="vertical" to stack the items. Arrow keys follow the orientation and wrap around, and Home and End focus the first and last enabled item.

<ToggleGroup orientation="vertical" defaultValue="a">
  <ToggleGroupItem value="a">Alpha</ToggleGroupItem>
  <ToggleGroupItem value="b">Beta</ToggleGroupItem>
</ToggleGroup>

Disabled

Set disabled on the group to disable every item, or on a single ToggleGroupItem.

<ToggleGroup defaultValue="a">
  <ToggleGroupItem value="a">Alpha</ToggleGroupItem>
  <ToggleGroupItem value="b" disabled>Beta</ToggleGroupItem>
</ToggleGroup>

Motion preferences

The gliding active pill and the shared hover highlight respect the browser's reduced-motion preference and the Kinetic reduced-motion setting. Timing follows the current tempo, and speed scales it for a single group.

API Reference

ToggleGroup

Zero-dependency single or multi-select toggle group with spring-gliding active indicator, shared hover highlight, and arrow-key navigation.

PropTypeDefaultDescription
type"single" | "multiple""single"Selection mode: single string with gliding pill or string[] with multi-active items.
variant / size / orientation"default" | "outline" / "sm" | "default" | "lg" / "horizontal" | "vertical""outline" / "default" / "horizontal"Visual variant, item dimensions, and group layout axis.
spacing / speednumber / number0 / 1Item spacing multiplier (0 for connected bar) and spring speed multiplier (0.25-4).

Notes

This Radix ToggleGroup requires type='single' or type='multiple' (never use a boolean multiple prop). Always provide aria-label or aria-labelledby on the group and aria-label on icon-only items.