Toggle groupPro
A row of toggles, single or multiple: one fill glides between options, or each fades in and neighbours join like a formatting toolbar.
oxyn add toggle-groupThe preview stays free for everyone. Pro opens the code of every Pro component, screen, agent-app template, block and kit, plus the Pro CLI.
Rendered from Rust at build time · goes live when visible
When to use
- Formatting toolbars, view toggles, tool sets in the composer.
When not to use
- Switch between two to six options: use Segmented Control instead.
- Choose which tools the agent may use: use Tools menu instead.
- On or off for things that apply right away: use Switch instead.
Installation
Toggle group is part of Oxyn Pro; the preview is free. Pro items install with the oxyn CLI once your licence is signed in; until then Pro members copy the code from this page.
oxyn add toggle-groupUsage
The preview is free. Pro opens the code of every Pro component, screen and template.
Examples
Toolbar
Formatting toolbar: pressed neighbours join.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
Single
Single choice: one fill glides.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
Text
Text options for agent mode.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
Dense
Small, for dense desktop toolbars.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
API reference
ToggleGroup
| Prop | Type | Default | Description |
|---|---|---|---|
itemsrequired | Vec<ToggleItem> | — | Items. |
labelrequired | String | — | Group name. |
multiple | bool | Default::default() | Multiple mode. |
value | Vec<String> | Default::default() | Pressed values. |
size | String | "md" | `sm` · `md`. |
disabled | bool | Default::default() | Disabled. |
on_change | EventHandler<Vec<String>> | — | New value(s). |
Read from the Rust signature and doc comments.
Keyboard interactions
| Key | Action |
|---|---|
| Tab | In and out on one item |
| ← → | Move focus (no press), wrapping |
| HomeorEnd | First / last |
| SpaceorEnter | Toggle or select |
Accessibility
- Single: radiogroup with radios and aria-checked. Multiple: group with aria-pressed.
- Icon-only items take their name and tooltip from label.
From the spec
Single → radiogroup / radio / aria-checked; multiple → group / aria-pressed; roving tab stop; fills aria-hidden.
Motion & interaction
Single: one fill glides to the chosen item. Multiple: each fill fades in from 86 % scale and pressed neighbours square their inner corners into one run. The icon dips to 92 % on press; the item box never scales.
Timing
| Transition | Duration | Easing | Reduced motion |
|---|---|---|---|
| Glide | 240 ms | ease.out | jump |
| Fill in | 180 ms + 220 ms scale | ease.out | instant |
| Press dip | 160 ms | ease.out | none |
Responsive behaviour
- Stays on one line; md items are 36 px for touch.
Edge cases (spec)
Icon-only items require label (tooltip and name). The strip never wraps; put groups in a wrapping row.
Notes for AI
- Import
ToggleGroupfromoxyn_dioxusand includePRIMITIVES_CSSplus the token stylesheet once. - A GPUI version exists:
ToggleGroupElinoxyn_gpui. - Props to set first:
items,label. - Keep its states and timings as they ship; restyle it through the CSS variables rather than by hand.