Components/Navigation/Sidebar
COMPONENT42.42

Sidebar

App shell with collapsible navigation — faint surface, accent-hover items, labeled groups, badges and submenus, no JavaScript.


INSTALL

1pnpm dlx @sayagodev/mo add sidebar

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

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

EXAMPLES

Demo
Hidden collapse
Right side
Custom shortcut
Header
Footer
Group
Group collapsible
Menu
Menu badge
Menu collapsible
Menu sub
Group action
Menu action

USAGE

1<div data-sidebar-layout>2  <aside data-sidebar>3    <header></header>4    <section data-sidebar-group>5      <div data-sidebar-label>Projects</div>6      <ul data-sidebar-menu>7        <li><a href="#" data-sidebar-item aria-current="page"></a></li>8        <li>9          <details open>10            <summary data-sidebar-item data-sidebar-sub-trigger></summary>11            <ul data-sidebar-sub><li><a data-sidebar-item href="#"></a></li></ul>12          </details>13        </li>14      </ul>15    </section>16    <footer></footer>17  </aside>18  <main></main>19</div>

API

NAMEKINDDESCRIPTION
[data-sidebar-layout]attributeApp shell grid; ="always" enables desktop collapse
<aside data-sidebar>elementPanel surface; header/nav/footer children
[data-sidebar-item]attributeRow; aria-current="page" activates accent state
[data-sidebar-label] / [data-sidebar-badge]attributeGroup heading · right count chip
[data-sidebar-sub] + [data-sidebar-sub-trigger]attributedetails/summary sub menu with rotating chevron
--sidebar-*tokenSurface, foreground, accent and border tokens with fallbacks

FILES

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

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
--accent--accent-foreground--background--border--foreground--primary--primary-foreground--radius--ring

Preview

Your CSS

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