Toggle
A two-state button that stays pressed or unpressed.
Usage
Toggle is a behavior primitive — it renders a <button aria-pressed> and ships no visual styling of its own. To make it look like anything, compose it with our Button through render={<Button …/>} (or apply buttonVariants({ variant, size }) as className). Button already reacts to the pressed state via data-pressed, so the pressed look comes for free.
Use it uncontrolled with defaultPressed, or controlled with pressed + onPressedChange. Every toggle needs an accessible name: give an icon-only toggle an aria-label, or use visible text children. To build a set of mutually-exclusive or multi-select toggles, group them in a ToggleGroup, where each Toggle carries a value.
Examples
Composing with Button
A toolbar of icon toggles, each rendered as an outline Button. The pressed state is styled automatically through data-pressed; the first toggle starts on with defaultPressed.
States
A toggle is off or on, and either state can also be disabled. disabled removes it from the tab order and exposes data-disabled for styling.
Controlled
Hold the state yourself with pressed + onPressedChange, then derive the rest of the UI from it. Here a single boolean drives the whole row — the bell icon, the button's variant, the accessible label, and the helper text all follow the toggle's value.
RTL
Every Appica UI component supports right-to-left layouts out of the box. Set the dir attribute on a container (commonly your <html> element) so CSS logical properties resolve correctly, and wrap your tree in DirectionProvider so direction-aware behavior — roving focus, popup placement, and the like — follows the same direction.
A row of toggles reorders from the start edge, following the resolved direction. For setup details and caveats, see the RTL guide.
API reference
Toggle wraps Base UI's Toggle and passes every remaining prop (ref, aria-*, and native <button> attributes) straight through. It exposes data-pressed and data-disabled state attributes for styling — see the Base UI docs for the full surface.
Accessibility
- Renders a
<button>witharia-pressedreflecting the current state. Space (or Enter) toggles it; Tab moves focus to and from it. - A toggle needs an accessible name — give an icon-only toggle an
aria-label, or use visible text children. disabledremoves the toggle from the tab order and exposesdata-disabledfor styling.- The pressed state is exposed as both
aria-pressed(for assistive tech) anddata-pressed(for styling) —Buttonuses the latter to paint its pressed look.