Components/Actions/Toggle
COMPONENT02.02

Toggle

Two-state button on aria-pressed — outline by default, ghost variant, accent surface when pressed.


INSTALL

1pnpm dlx @sayagodev/mo add toggle

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

1import "@sayagodev/mo/css/toggle.css";

EXAMPLES

Bookmark
Outline icons
With text
Sizes
Disabled

USAGE

1<button aria-pressed="false">2  <svg/>3  Bookmark4</button>5 6<button class="ghost" aria-pressed="true">Pressed</button>

API

NAMEKINDDESCRIPTION
[aria-pressed]attributeSelects the component; "true" is the on state
.ghostattributeBorderless variant
.small / .largeclassh-6 / h-10 sizes
--mo-toggle-bgtokenPressed surface color hook

FILES

src/css/toggle.css
Install:mo add toggle

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
--foreground--muted--radius
Component hooks
--mo-toggle-bg

Preview

Your CSS

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