Toggle Group

Provides a shared state to a series of toggle buttons.

Base UI React 1.8.0
FineSoft Stencil

The Stencil example uses fs-toggle-group with fs-toggle children. The group owns selection, disabled inheritance, and keyboard focus; no example-specific controller is needed. Use array properties for value / defaultValue, or JSON arrays in HTML attributes such as default-value='["left"]'. The cancelable valueChange event exposes the requested array as event.detail.value; a controlled consumer writes that array back to value.

The Stencil container uses Shadow DOM and exposes ::part(group); each Toggle exposes ::part(control). The Base UI theme is built in; set data-fs-theme="base-ui" on an ancestor to apply the optional theme without component classes. Override the existing --fs-toggle-group-* variables or use the public parts for custom styles.

React’s render API is not a Web Component property; use slotted content and public events. Inside fs-toolbar-root, the migrated toolbar supplies outer composite navigation and disabled inheritance; the group does not create a second tab stop or trap arrow navigation. A Stencil group still does not consume React Toolbar context; compose the Stencil toolbar parts together.

Anatomy

Import the component and use it as a single part:

Anatomy

Examples

Multiple

Add the multiple prop to allow pressing more than one toggle at a time.

Base UI React 1.8.0
FineSoft Stencil

API reference

defaultValuestring[]
Description

The pressed state of the toggle group represented by an array of the values of all pressed toggle buttons. This is the uncontrolled counterpart of value.

Type
valuestring[]
Name
Description

The pressed state of the toggle group represented by an array of the values of all pressed toggle buttons. This is the controlled counterpart of defaultValue.

Type
onValueChangefunction
Description

Callback fired when the pressed states of the toggle group changes.

Type
loopFocusbooleantrue
Description

Whether to loop keyboard focus back to the first item when the end of the list is reached while using the arrow keys.

Type
Default
true
multiplebooleanfalse
Description

When false only one item in the group can be pressed. If any item in the group becomes pressed, the others will become unpressed. When true multiple items can be pressed.

Type
Default
false
disabledbooleanfalse
Description

Whether the toggle group should ignore user interaction.

Type
Default
false
orientationOrientation'horizontal'
Type
Default
'horizontal'
classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Description

Style applied to the element, or a function that returns a style object based on the component’s state.

Type
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-orientation

Indicates the orientation of the toggle group.

data-disabled

Present when the toggle group is disabled.

data-multiple

Present when the toggle group allows multiple buttons to be in the pressed state at the same time.

Attribute
Description
data-orientation

Indicates the orientation of the toggle group.

data-disabled

Present when the toggle group is disabled.

data-multiple

Present when the toggle group allows multiple buttons to be in the pressed state at the same time.

ToggleGroup.PropsHide

Re-Export of ToggleGroup props as ToggleGroupProps

ToggleGroup.StateHide

ToggleGroup.ChangeEventReasonHide

ToggleGroup.ChangeEventDetailsHide