Components

Toggle

A two-state button that can be turned on or off — ideal for icon controls in toolbars and inline formatting actions.

Basic usage

Wrap a Lucide icon and provide an aria-label. Click to flip between on and off.

Variants

Use default for toolbar groups and outline for standalone controls that need a visible boundary.

Sizes

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

States

Start a toggle in the on position with defaultPressed, or block interaction with disabled. Toggles can pair an icon with a text label.

Props

PropTypeDefaultDescription
variant'default' | 'outline''default'Visual style — transparent by default, or bordered for standalone controls.
size'sm' | 'default' | 'lg''default'Controls height and horizontal padding of the toggle.
pressedbooleanControlled on/off state. Pair with onPressedChange.
defaultPressedbooleanfalseInitial pressed state when uncontrolled.
onPressedChange(pressed: boolean) => voidFires when the pressed state changes.
disabledbooleanfalseDisables interaction and reduces opacity to 50%.
classNamestringAdditional Tailwind classes to merge.
...restRadix Toggle.Root propsAll Radix Toggle root props are forwarded.

Accessibility

  • Built on Radix Toggle, which exposes the on/off state to assistive tech via aria-pressed.
  • Always pass an aria-label for icon-only toggles so the control has an accessible name.
  • Fully keyboard operable — focus with Tab and flip with Enter or Space.
  • A focus-visible ring using the brand gold ring token appears on keyboard navigation and stays hidden on click.
  • The disabled state removes pointer events and is conveyed to the accessibility tree.