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.

Source on GitHub

Variants · off and on
offonon · teal subtle (default)FavoriteFavoriteFavorite outlineWrap linesWrap linesWrap lines lightMuteMuteMute filledLiveLiveLive raisedPowerPowerPower

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.

Icon toggles

For toolbars where toggles share one value (bold / italic, alignment), see ray-toggle-group.

Sizes and states
xs sm md lg Disabled on Disabled off

Flip a toggle to see its change event.

Code

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.

PropertyAttributeTypeDefaultDescription
pressedpressed reflectsbooleanOn.
variantvariant reflectssubtle | outline | light | filled | raisedsubtleLook 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.
squaresquare reflectsbooleanSquare, for an icon alone (give it a label).
labellabel reflectsstringAccessible name and tooltip, for icon-only toggles.
EventDescription
changeThe user flipped it (read `pressed`).
SlotDescription
(default)Text or an icon.