Skip to content
Zuno UI
Explore components
EXPLORE
Actions
Forms
Layout
Navigation
Data display
Feedback
Overlays
RESOURCES
Components/Toggle

Toggle

A two-state button with a recognizable pressed state.

Base UI reference ↗

Installation

Run it from the root of a project already set up with zunoui init.

npx zunoui@latest add toggle

Dependencies

What add toggle installs alongside the component. The CLI skips any you already have in a compatible version.

ZUNO registry

  • @zuno/utils

npm

Examples

3 examples · 1 component
toggle

Icon toggles

Constant labels through aria-label; the state is announced as pressed.

toggle

Outline with text

variant="outline" for a toggle that sits among fields.

toggle

Sizes and disabled

sm, default and lg (44 px target); disabled blocks interaction.

API reference

Keeps the props, events and refs of the matching Base UI primitive, plus ZUNO's styles.

PropTypeDefault
variant

Transparent or bordered surface.

"default" | "outline""default"
size

32, 36 or 44 px tall; lg meets the 44 px touch target.

"sm" | "default" | "lg""default"
pressed / defaultPressed

Controlled or uncontrolled state.

booleanfalse
onPressedChange

Called when the state changes.

(pressed: boolean) => void—
disabled

Dims the toggle and blocks interaction.

booleanfalse
toggleClasses

The exported class recipe, shared with ToggleGroupItem.

(variant, size) => string—

States

The states that apply to this component and their visual treatment.

StateTreatment
OffTransparent or bordered, with hover feedback.
OnAccent fill (data-pressed).
FocusOffset outline.
DisabledDimmed; no pointer events.

Accessibility

It is a button with aria-pressed, so screen readers announce "pressed" or "not pressed"; Space and Enter toggle it.

Keep the label constant ("Bold"), not the action ("Make bold"): the pressed state already tells whether it is on.

Icon-only toggles need an aria-label; the pressed state uses a fill change, not color alone on the icon.