Skip to content
SENVENLI UI

Toggle button

A button that stays pressed or not, alone or in a group where one or several options are on.
Filters that combine
import { ToggleButton, ToggleGroup } from "@senvenli/react/action";

Examples

One choice

With `selectionMode="single"` the group behaves as a radio group.

A single toggle, controlled

The label stays the same; only the pressed state changes.

Compact and disabled

Compact for dense toolbars; a disabled toggle keeps its state.

Guidelines

When to use it

  • Turning a formatting or view option on and off.
  • Picking options from a short group (ToggleGroup).

Use something else when

  • The choice is a setting that applies immediately. Switch
  • The choice switches between views of the same content; use SegmentedControl from Tabs. Tabs

Accessibility

Keyboard

KeysWhat happens
Space, EnterToggles the button.
Arrow keysMoves between buttons in a group.

Built in

  • The pressed state is announced; the label never changes with the state.

You provide

  • A label that names a ToggleGroup.

API reference

ToggleButton

childrenRequired
React.ReactNode

The label never changes with the state; aria-pressed carries it.

icon
IconName

Lucide icon name before the label.

size
ToggleSize
radius
ComponentRadius

Corner radius; the provider's default otherwise.

Also takes 82 standard DOM and ARIA attributes (id, aria-label, event handlers…).

ToggleGroup

labelRequired
string

Names the group ("Text alignment").

childrenRequired
React.ReactNode

Also takes 81 standard DOM and ARIA attributes (id, aria-label, event handlers…).