Toggle

A two-state button that switches between on and off. Built on Radix UI Toggle — handles pressed state, ARIA, and keyboard interaction automatically.

Built on Radix UI.

  • Two variants: default (ghost-style) and outline (bordered)
  • Three sizes: sm, default, lg
  • Controlled and uncontrolled modes via pressed / defaultPressed
  • Built-in ARIA pressed state — screen readers announce on/off
  • First-class Lucide icon support — icons auto-sized to 16px
  • Forwards ref to the underlying element

import { Toggle }from "@aetherstack/ui"

toggle.tsx
import { Toggle } from "@/components/ui/toggle"
import { Bold } from "lucide-react"

export function ToggleDemo() {
  return (
    <Toggle aria-label="Toggle bold">
      <Bold />
    </Toggle>
  )
}

Usage

Default

The default ghost-style toggle. Background fills on hover; accent fill when pressed.

Outline variant

A bordered toggle for use in toolbars where visual separation is needed.

Sizes

Three sizes — sm, default, and lg — to match surrounding UI density.

Disabled

Disabled toggles are non-interactive and visually dimmed.

Props

PropTypeDefaultDescription
variant"default" | "outline""default"Visual style. Default is ghost-style; outline adds a border.
size"default" | "sm" | "lg""default"Controls padding and height.
pressedbooleanControlled pressed state. Use with onPressedChange.
defaultPressedbooleanfalseUncontrolled initial pressed state.
onPressedChange(pressed: boolean) => voidCallback fired when the pressed state changes.
disabledbooleanfalsePrevents interaction and applies reduced opacity.
classNamestringAdditional class names merged onto the toggle element.

* Required props

Accessibility

  • Has role='button' with aria-pressed — screen readers announce the current on/off state.
  • Always provide aria-label when the toggle contains only an icon.
  • Keyboard accessible — toggle with Enter or Space.
  • Focus ring is always visible on keyboard navigation (focus-visible).
  • Disabled state has aria-disabled='true' and prevents all pointer events.