Components/Actions/Toggle Group
COMPONENT03.03

Toggle Group

Two-state buttons orchestrated by <mo-toggle-group>: single-select or multi-select in joined segments.


INSTALL

1pnpm dlx @sayagodev/mo add toggle-group

Or import the files from the package (no copy):

1import "@sayagodev/mo/css/toggle-group.css";2import "@sayagodev/mo/js/toggle-group.js";

EXAMPLES

Multiple icons
Outline single
Sizes
Spacing
Vertical
Disabled
Font weight selector

USAGE

1<mo-toggle-group type="multiple">2  <button type="button" value="bold" aria-pressed="true"><svg/></button>3  <button type="button" value="italic" aria-pressed="false"><svg/></button>4</mo-toggle-group>

API

NAMEKINDDESCRIPTION
<mo-toggle-group>elementOrchestrator over button[aria-pressed] children
typeattributesingle (default) · multiple
collapsibleattributeSingle groups allow unpressing the active item
[data-orientation="vertical"] / [data-spacing]attributeStack or separate segments
mo-toggle-changeelementCustom event, detail { values } after every change
--mo-toggle-bgtokenPressed segment surface (default muted, like shadcn data-state=on)
--mo-toggle-group-gaptokenGap between separated segments (data-spacing 1·2)

FILES

src/css/toggle-group.csssrc/js/toggle-group.js
Install:mo add toggle-group

THEMING · PLAYGROUND

This is the exact component from the examples above, wearing a completely different theme. Edit the tokens and --mo-* hooks in the editor — autocomplete knows them all — and the preview obeys in real time. Your CSS always wins.

Tokens & hooks — edit live
Global tokens
--border--foreground--input--muted--radius
Component hooks
--mo-toggle-bg--mo-toggle-group-gap

Preview

Your CSS

Try it: type --mo- for the component hooks, or edit any value — the preview obeys in real time.