videorc/ui

Toggle Group

Filter chips on Base UI. Pressed items wear the chrome plate, a Field's label names the group, and items can sit apart, wrap, or join into one outlined strip.

Installation

$ pnpm dlx shadcn@latest add @videorc/toggle-group

Usage

import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
<ToggleGroup aria-label="Chat filters" multiple>
  <ToggleGroupItem value="questions">Questions</ToggleGroupItem>
  <ToggleGroupItem value="mentions">Mentions</ToggleGroupItem>
</ToggleGroup>

Anatomy

<ToggleGroup>
  <ToggleGroupItem />
</ToggleGroup>

Examples

Filter chips

multiple lets several chips stay on. size="xs" and spacing={1} make the dense chip row Videorc uses to choose which kinds of cuts to review; flex-wrap lets a narrow pane wrap it.

Joined

spacing={0} with variant="outline" joins the items into one strip with shared hairlines, rounded at the ends.

Theming

Token or attributeMeaning
chrome-plateA pressed item, keyed off data-pressed
rounded-chip, rounded-rowAn item, and the ends of a joined strip
h-control, h-6The default and xs item heights
--gapThe space between items, set from spacing
data-variant, data-size, data-spacingOn the group and every item, for styling from a parent
data-orientationhorizontal or vertical, from orientation

Keyboard

KeyAction
TabMoves focus into the group, then out of it
ArrowRight, ArrowLeftMoves between items in a horizontal group, wrapping
ArrowDown, ArrowUpMoves between items in a vertical group, wrapping
Space, EnterPresses or releases the focused item

Accessibility

The group is a group and every item a <button> with aria-pressed. Name the group with aria-label, or put it in a Field: its label names the group through aria-labelledby unless the group carries its own aria-label. An icon-only item needs its own aria-label.

ToggleGroup is for filters. Choosing exactly one value among 2–4 options is Segmented control, which is a radio group to assistive tech.

API reference

ToggleGroup

Every Base UI Toggle Group prop, plus:

Prop

Type

ToggleGroupItem

Every Base UI Toggle prop. value names the item in the group's array; variant and size apply when the group sets none.