Toggle
Two-state pressable button (on/off) built on Base UI Toggle, with an optional
icon alongside the label.
Pass icon with no children to get a square icon-only toggle (auto-detected
and sized to match its height); pass both for an icon + label. Controlled via
pressed/onPressedChange, uncontrolled via defaultPressed.
Inside a ToggleGroup it is the group's item, as in Base UI: give it a
value, and it takes the group's size, radius, variant and layout in
place of its own. An icon-only toggle needs an aria-label; a dev warning
fires without one.
Usage
Best practices
One independent on/off is a
Toggle; a mutually-exclusive or multi-select set isToggleGroupwithToggles inside it; an instantly-applied setting isSwitch.Pass
iconwith no children for a square icon-only toggle (auto-sized); with a label, order it viaiconPlacement.
Props
Also exports
- type
ToggleRadius - type
ToggleSize - const
toggleVariants
Composition
Builds on
Used by