ValyroUI Русская версия

Toggle Group

Pressed-state buttons: formatting, alignment, filters. Free, MIT · Navigation and layout › Switching

Installation

npx valyro-cli@latest add toggle-group
npx shadcn@latest add https://valyro.xyz/r/toggle-group.json
npm install valyro-ui

import 'valyro-ui/styles.css';
import { ToggleGroup } from 'valyro-ui';

Props

PropTypeDefault
itemsreadonly ToggleGroupOption[]The buttons in order. Or compose them as children: ToggleGroup.Item.
childrenReactNodeThe compound form instead of items: ToggleGroup.Item elements.
typeMsingle: at most one pressed (alignment); multiple: any number (bold, italic, underline).
valueToggleGroupValue<M>The pressed value (single, null for none) or values (multiple).
defaultValueToggleGroupValue<M>Initial value when uncontrolled.
onValueChange(value: ToggleGroupValue<M>) => voidCalled with the new value when it changes.
allowEmptybooleantruesingle: pressing the pressed button releases it.
orientation'horizontal' | 'vertical''horizontal'A row or a column; arrow keys follow it.
loopbooleantrueArrow keys wrap from the last button to the first.
disabledbooleanfalseDisables every button.
attachedbooleantrueJoined into one control on a shared track; false spaces the buttons apart and lets the row wrap.
size'sm' | 'md' | 'lg''md'Button height and text size.
indicatorbooleanfalsesingle: one pressed fill slides between the buttons instead of each button filling on its own.
labelsPartial<ToggleGroupLabels>Overrides for the built-in English text; keys left out keep their defaults.

Compound parts

ToggleGroup.Item (ToggleGroupItem)

Related components

Previous: Segmented Control · Next: Pagination · All Navigation and layout