# Toggle primitive
Source: https://texuli.com/primitives-page/toggle/
# Toggle
A pressed/unpressed button, alone or in a group.
Import
`import { Toggle, ToggleGroup } from '@texuli/primitives/toggle';`
Pattern
[Button (toggle) (WAI-ARIA APG)](https://www.w3.org/WAI/ARIA/apg/patterns/button/)
Size budget
5.0 KiB gzip for @texuli/primitives/toggle
Reference
`packages/primitives/docs/prim-toggle.md`
## Live demo
Right to left
Loading the Toggle demo…
## Anatomy
Toggle anatomy: each box holds the parts inside it.
- `Toggle.Root`
- `ToggleGroup.Root``ToggleGroup.Item`
## Behavior checks
`tests/behavior/scenarios/toggle.spec.ts` runs **5 rows** against the Toggle scenario on Chromium, WebKit and the Pixel 7. Each row asserts what a user or assistive technology can observe, held to the WAI-ARIA Authoring Practices pattern.
All 5 rows
- a toggle starts off and click toggles aria-pressed on and off
- a disabled toggle cannot change
- single group selects one value and clears on second press
- multiple group keeps independent pressed items
- arrow keys move focus between group items
### Limits
- Every row passes on every project; a flaky row gets at most two retries.
- Size: at most 5.0 KiB gzip for `@texuli/primitives/toggle` (`pnpm size`).
- Open-to-focus: p75 at most 150 ms (asserted with `TEXULI_PERF=1`).
Toggle
A pressed/unpressed button, alone or in a group.
- Import
import { Toggle, ToggleGroup } from '@texuli/primitives/toggle';- Pattern
- Button (toggle) (WAI-ARIA APG)
- Size budget
- 5.0 KiB gzip for @texuli/primitives/toggle
- Reference
packages/primitives/ docs/ prim-toggle.md
Loading the Toggle demo…
Anatomy
Toggle.RootToggleGroup.RootToggleGroup.Item
Behavior checks
tests/behavior/scenarios/toggle.spec.ts runs 5 rows against the Toggle scenario on Chromium, WebKit and the Pixel 7. Each row asserts what a user or assistive technology can observe, held to the WAI-ARIA Authoring Practices pattern.
All 5 rows
- a toggle starts off and click toggles aria-pressed on and off
- a disabled toggle cannot change
- single group selects one value and clears on second press
- multiple group keeps independent pressed items
- arrow keys move focus between group items
Limits
- Every row passes on every project; a flaky row gets at most two retries.
- Size: at most 5.0 KiB gzip for
@texuli/primitives/toggle(pnpm size). - Open-to-focus: p75 at most 150 ms (asserted with
TEXULI_PERF=1).