ToggleGroup

Two-state buttons (aria-pressed). Use Toggle for one option that stays on, and ToggleGroup for a set: type="single" is a deselectable choice, type="multiple" independent toggles.

StableSource
value: "left"

Import

import { Toggle, ToggleGroup, ToggleGroupItem } from "@meridui/react";

Examples

Multiple

value: ["bold"]

Toggle

API reference

Toggle

Accepts every <button> attribute; the ref goes to the button.

PropTypeDefaultDescription
pressedboolean–Controlled pressed state.
defaultPressedbooleanfalseInitial state when uncontrolled.
onPressedChange(pressed: boolean) => void–Called with the new state.
size"sm" | "md" | "lg""md"Height.

ToggleGroup

Renders a div role="group"; name it with aria-label or aria-labelledby.

PropTypeDefaultDescription
typeRequired"single" | "multiple"–One item on at a time (pressing it again turns it off), or any number.
valuestring | string[]–Controlled value: string ("" for none) or string[].
defaultValuestring | string[]–Initial value when uncontrolled.
onValueChange(value) => void–Called with the new value.
orientation"horizontal" | "vertical""horizontal"Which arrow keys move focus, and the layout.
size"sm" | "md" | "lg""md"Size of every item.
disabledbooleanfalseDisables every item.

ToggleGroupItem

Accepts every <button> attribute except value.

PropTypeDefaultDescription
valueRequiredstring–Value reported when this item is on.
disabledboolean–Disables the item; arrow keys skip it.

Styling

ClassElement
.mrd-toggleToggle and every group item (data-state="on" | "off", data-size)
.mrd-toggle-groupGroup (data-orientation)
.mrd-toggle-group__itemGroup item

Accessibility

Every item is a <button aria-pressed>, so screen readers announce "pressed" / "not pressed". The group is one tab stop (roving tabindex); arrow keys move focus without changing the state, Space or Enter toggles. Icon-only items need an aria-label.

KeyAction
TabMove into the group (to the pressed item or the first) and out of it.
ArrowRightArrowDownNext item (wraps; ArrowLeft in RTL).
ArrowLeftArrowUpPrevious item (wraps).
HomeEndFirst / last item.
SpaceEnterToggle the focused item.

Guidelines

Do

Use a single ToggleGroup for tool options that apply immediately, like text alignment.

Avoid

Use it to switch between views or pages; that is SegmentedControl or Tabs.