Toggle

A button that stays on or off, such as Bold in a text toolbar.
Stable
Web
iOS
Android
@advui/core
Source
JSX
<Toggle>Italic</Toggle>
variant
size

Installation

pnpm
pnpm add @advui/core
npm
npm install @advui/core

Usage

import { Toggle } from '@advui/core'
import { BoldIcon } from '@advui/icons'

<Toggle aria-label="Bold" icon={<BoldIcon />} />
<Toggle pressed={muted} onPressedChange={setMuted}>Mute</Toggle>

Examples

Icon, text and disabled

Controlled

The label stays the same; the state is announced as pressed.
Not saved yet.

API reference

Toggle

PropTypeDefaultDescription
pressedboolean—On or off, when you control it.
defaultPressedbooleanfalseStarting `pressed` when uncontrolled.
onPressedChange(pressed: boolean) => void—Called when the user turns it on or off.
variant'default' | 'outline''default'Transparent, or with a border.
size'sm' | 'md' | 'lg''md'Height.
iconReactNode—Icon before the label.
disabledbooleanfalseNot interactive.
aria-labelstring—Required for icon-only toggles. Keep it the same in both states.

Accessibility

  • On web it is a <button> with aria-pressed; on iOS and Android a toggle button whose state is read as on or off.
  • Keep the label the same in both states: the pressed state already says whether it is on. Use Switch for settings that apply at once.
  • The on state changes the background color, not only a small detail, so it is easy to see.
  • Touch targets are at least 44pt on native.
Keyboard interactions
KeyAction
Space / EnterTurns the toggle on or off.

Platform notes

Web
A native <button type="button">.
iOS
VoiceOver reads “toggle button”, then on or off.
Android
TalkBack reads “toggle button”, then on or off. With androidRipple (on in material()), presses show the native ripple.
Since v0.2.0Last updated Nov 2, 2026Edit this page on GitHub