Toggle
A two-state button (aria-pressed): bold in a toolbar, mute, favorite. The variant is how "on" looks; "off" is always neutral, so the states differ by more than color. Has everything ray-button has and joins a ray-button-group.
Click any of them. Off is always neutral, so on differs by more than color. ray-button's default, transparent and gradient are not toggle variants.
For toolbars where toggles share one value (bold / italic, alignment), see ray-toggle-group.
Flip a toggle to see its change event.
API
For AI agents: this API as Markdown, or every component in llms-full.txt.
<ray-toggle> · RayToggle
Click, Enter or Space flips pressed and fires change. In a form it is submitted like a checkbox: value (default "on") under name while pressed; reset restores the initial pressed attribute.
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
pressed | pressed reflects | boolean | On. | |
variant | variant reflects | subtle | outline | light | filled | raised | subtle | Look of "on": subtle (tint), outline (colored border + tint), light (muted → tint), filled (surface → solid color), raised (a key that latches down, lit). ray-button's default, transparent and gradient are left out: no distinct on state, or only a color change. |
square | square reflects | boolean | Square, for an icon alone (give it a label). | |
label | label reflects | string | Accessible name and tooltip, for icon-only toggles. |
| Event | Description |
|---|---|
change | The user flipped it (read `pressed`). |
| Slot | Description |
|---|---|
| (default) | Text or an icon. |