Toggle Group

A set of two-state buttons that can be toggled on or off, with support for single or multiple selection.

Overview

The ToggleGroup component manages related toggle buttons. Use the default variant for lightweight ghost-button groups, the outline variant for bordered groups, and the segmented variant for single-selection controls with an animated thumb.

Usage

import {
  ToggleGroup,
  ToggleGroupItem,
} from "@tilt-legal/cubitt-components/toggle-group";
<ToggleGroup defaultValue="center" groupVariant="segmented">
  <ToggleGroupItem value="left">Left</ToggleGroupItem>
  <ToggleGroupItem value="center">Center</ToggleGroupItem>
  <ToggleGroupItem value="right">Right</ToggleGroupItem>
</ToggleGroup>

Examples

Segmented

Single-selection segmented groups use the same track, thumb, separator, and hover model as Tabs.

Default

Default groups behave like related ghost toggles and support multiple active items.

Outline

Outline groups add a contextual border around related toggle items.

Sizes

Segmented groups support text and icon-only layouts at each size.

Separator

Use ToggleGroupSeparator inside segmented groups to split related options. Separators hide when the active thumb touches them.

URL State

Sync toggle group selection with the URL.

Polymorphic

Render items through custom elements while preserving pressed state.

API Reference

ToggleGroup

The root container that manages toggle selection.

PropTypeDefaultDescription
valuestring | string[]-Controlled selected value or values.
defaultValuestring | string[]-Initial selected value or values for uncontrolled usage.
onValueChange(value: string | string[]) => void-Called when selection changes.
multiplebooleanautoEnables multiple selection. Segmented groups always use single selection.
groupVariant"default" | "outline" | "segmented""default"Visual group style.
variant"default" | "outline""default"Toggle item variant for non-segmented groups.
size"sm" | "md" | "lg""md"Toggle item size.
disabledbooleanfalseDisables the whole group.
loopbooleantrueWhether keyboard focus loops.
orientation"horizontal" | "vertical""horizontal"Group orientation.
classNamestring-Additional classes for layout.

URL State Props

PropTypeDefaultDescription
paramNamestring-Search parameter name used for URL state.
onUrlValueChange(value: string | string[] | null) => void-Called when the URL-backed value changes.
paramClearOnDefaultbooleantrueRemoves the URL parameter when value matches the default.
paramThrottlenumber-Throttles URL updates in milliseconds.
paramDebouncenumber-Debounces URL updates in milliseconds.

ToggleGroupItem

PropTypeDefaultDescription
valuestring-Required unique item value.
mode"icon"-Square icon-only sizing. Segmented icon items render circular.
disabledbooleanfalseDisables one item.
variant"default" | "outline"inheritedOverrides the item variant for non-segmented groups.
size"sm" | "md" | "lg"inheritedOverrides the item size.
renderReactElement | function-Renders as a custom element or component.
nativeButtonbooleantrueSet to false when render outputs a non-button element.
classNamestring-Additional item classes.
childrenReact.ReactNode-Item content.

ToggleGroupSeparator

PropTypeDefaultDescription
classNamestring-Additional separator classes.

Notes

  • Use multiple for multi-select default or outline groups.
  • Segmented groups force single selection so the animated thumb always has one target.
  • Use aria-label for icon-only items.
  • The segmented variant respects prefers-reduced-motion.

On this page