Toggle

A standalone pressed button primitive with controlled and uncontrolled state.

Features

  • Standalone pressed button
  • Controlled or uncontrolled state
  • aria-pressed reflection
  • data-state state
  • Headless primitives

Installation

npm install @ariaui/toggle

Examples

These playgrounds mirror individual shadcn Figma toggle states with @ariaui/toggle. Use it for one independent pressed button with controlled or uncontrolled state.

Icon rows use lucide-react; shared class strings live in toggleExampleTokens.ts.

Default

Standalone icon-only toggle.

Preview

No preview output yet.

live.tsxReady

Outline

Visible border on the item for an outlined treatment.

Preview

No preview output yet.

live.tsxReady

With text

Icon plus visible label in a wider control.

Preview

No preview output yet.

live.tsxReady

Small

Preview

No preview output yet.

live.tsxReady

Large

Preview

No preview output yet.

live.tsxReady

Disabled

Disabled standalone toggle with muted styling.

Preview

No preview output yet.

live.tsxReady

Anatomy

tsx
import * as Toggle from "@ariaui/toggle";

export default function Example() {
  return <Toggle.Root />;
}

API Reference

Root

Standalone pressed button. Renders a native `<button type="button">` and forwards button props.

PropTypeDefault
pressed
boolean
defaultPressed
booleanfalse
onPressedChange
(pressed: boolean) => void
disabled
booleanfalse
AttributeValues
aria-pressed`true` when pressed, `false` when not pressed
data-state`on` when pressed, `off` when not pressed
data-disabledpresent when disabled

Keyboard

ShortcutAction
Space/EnterToggle a standalone Toggle.Root button.

Accessibility

Toggle.Root renders a native button with aria-pressed, so screen readers can announce the on/off state. Use an accessible label for icon-only toggles.

Standalone toggle visual state is exposed via data-state. Use ToggleGroup when related toggles need shared single or multiple selection state.

Previous
Toast