Components/Surfaces/Tabs
COMPONENT27.27

Tabs

Tabbed panels in <mo-tabs> with roving-tabindex arrows and hash deep-linking. Panels toggle via hidden.


INSTALL

1pnpm dlx @sayagodev/mo add tabs

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

1import "@sayagodev/mo/css/tabs.css";2import "@sayagodev/mo/js/tabs.js";

EXAMPLES

Default

Make changes to your account here. Arrow keys move between tabs.

Change your password here. Panels toggle through the hidden attribute.

Configure how you get notified.

With icons

Rendered output of your component.

Source code of your component.

Disabled tab

Welcome home. The disabled tab cannot be activated.

Line

Overview panel. data-variant="line" swaps the pill for a 2px underline.

Analytics panel. Arrow keys still move between tabs.

Reports panel.

Vertical

Make changes to your account here. ArrowUp and ArrowDown move between tabs.

Change your password here. Panels toggle through the hidden attribute.

Configure how you get notified.

USAGE

1<mo-tabs>2  <div role="tablist">3    <button role="tab" aria-selected="true">One</button>4    <button role="tab" aria-selected="false">Two</button>5  </div>6  <div role="tabpanel"></div>7  <div role="tabpanel" hidden></div>8</mo-tabs>

API

NAMEKINDDESCRIPTION
<mo-tabs>elementRoving tabindex, arrow keys, hash deep-linking
[data-anchor]attributeSync active tab id to URL hash key
data-orientation="vertical"attributeColumn tablist, start-aligned tabs; Up/Down navigate
[role="tablist"][data-variant="line"]attributeTransparent track; active tab gets a 2px underline
activeIndexelementJS getter/setter for programmatic control
--mo-tabs-radius / -list-bgtokenShape and track hooks

FILES

src/css/tabs.csssrc/js/tabs.js
Install:mo add tabs

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
--background--foreground--input--muted--muted-foreground--radius--ring
Component hooks
--mo-tabs-active-bg--mo-tabs-height--mo-tabs-list-bg--mo-tabs-radius--mo-tabs-vertical-gap

Preview

The overview reads straight from the bench sensors.

Your CSS

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