1. framework components
  2. toggle group

Toggle Group

Grouped buttons for toggling option states.

Warning

This feature is currently marked as beta and not intended for production use. It may receive breaking changes before its stable release.

Controlled

Use the value and onValueChange props to control state programmatically.

You selected bold

Orientation

Using the orientation prop to control the layout.

Horizontal

Vertical

Direction

Set the text direction (ltr or rtl) using the dir prop.

API Reference

Root

txt
inline-flex preset-outlined-surface-200-800 divide-surface-200-800 overflow-hidden rounded-base data-[orientation=horizontal]:divide-x data-[orientation=vertical]:divide-y data-[orientation=horizontal]:flex-row data-[orientation=vertical]:flex-col
PropDefaultType
idsPartial<{ root: string; item: (value: string) => string; }> | undefined

The ids of the elements in the toggle. Useful for composition.

disabledboolean | undefined

Whether the toggle is disabled.

valuestring[] | undefined

The controlled selected value of the toggle group.

defaultValuestring[] | undefined

The initial selected value of the toggle group when rendered. Use when you don't need to control the selected value of the toggle group.

onValueChange((details: ValueChangeDetails) => void) | undefined

Function to call when the toggle is clicked.

loopFocustrueboolean | undefined

Whether to loop focus inside the toggle group.

rovingFocustrueboolean | undefined

Whether to use roving tab index to manage focus.

orientation"horizontal"Orientation | undefined

The orientation of the toggle group.

multipleboolean | undefined

Whether to allow multiple toggles to be selected.

deselectabletrueboolean | undefined

Whether the toggle group allows empty selection. **Note:** This is ignored if `multiple` is `true`.

dir"ltr""ltr" | "rtl" | undefined

The document's text/writing direction.

getRootNode(() => ShadowRoot | Node | Document) | undefined

A root node to correctly resolve document in custom environments. E.x.: Iframes, Electron.

element((attributes: HTMLAttributes<"div">) => Element) | undefined

Render the element yourself

Provider

PropDefaultType
valueToggleGroupApi<PropTypes>

element((attributes: HTMLAttributes<"div">) => Element) | undefined

Render the element yourself

Context

PropDefaultType
children(togglegroup: ToggleGroupApi<PropTypes>) => ReactNode

Item

txt
flex justify-center items-center w-9 aspect-square hover:preset-tonal data-[state=on]:preset-filled data-focus-visible:outline-2 data-focus-visible:outline-offset-1 data-focus-visible:outline-surface-950-50 data-readonly:pointer-events-none data-disabled:pointer-events-none data-disabled:opacity-50
PropDefaultType
valuestring

disabledboolean | undefined

element((attributes: HTMLAttributes<"button">) => Element) | undefined

Render the element yourself

View page on GitHub