Navigation and overlays
Sidebar
An app sidebar with a header, titled sections, icon items, badges, collapsible groups on <details>, a footer and a compact icon only mode.
Example
Classes
11 classes. Click a name to copy it. Utilities on the same element always win over component defaults, so any of them can be adjusted with plain utility classes.
| Class | Type | What it does |
|---|---|---|
| Base | Base class of the sidebar. On an <aside> in the example. Sets flex display, alignment, gap, width, height and padding, and --tone, --tone-fg and --sidebar-w.CSS |
|
| Part | Part of the sidebar. On a <div> in the example. Sets flex display, alignment, gap, height, padding and font weight.CSS |
|
| Part | Part of the sidebar. On a <nav> in the example. Sets flex display, alignment and gap.CSS |
|
| Part | Part of the sidebar. On a <p> in the example. Sets padding, text size, font weight, text color, text style and absolute position.CSS |
|
| Part | Part of the sidebar. On an <a> in the example. Sets flex display, alignment, gap, width, height and padding.CSS |
|
| Modifier | Modifier, combined with the sidebar class. Not used in the example above. Sets text color and background.CSS |
|
| Part | Part of the sidebar. On a <span> in the example. Sets alignment, width, overflow and text style.CSS |
|
| Part | Part of the sidebar. On a <span> in the example. Sets inline-grid display, alignment, width, height, margin and padding.CSS |
|
| Part | Part of the sidebar. On a <details> in the example. Sets pointer cursor, hidden by default, generated content, width, height and margin.CSS |
|
| Part | Part of the sidebar. On a <div> in the example. Sets flex display, alignment, gap, margin, padding and border.CSS |
|
| Modifier | Modifier, combined with the sidebar class. Not used in the example above. Sets alignment, width, height, padding, absolute position and overflow, and --sidebar-w.CSS |
Usage
Components ship inside the same stylesheet as the utilities. There is nothing else to install and no script to load: link Monsoon and write the markup.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/monsooncss">
<!-- Sidebar: start from the base class, then add modifiers -->
<aside class="sidebar h-96"><div class="sidebar-header"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 15a8 8 0 0 1 16 0"/><path d="M12 15v5a2 2 0 0 1-4 0"/><path d="M12 7V4"/></svg><span class="sidebar-label">Acme Inc</span></div><nav class="sidebar-section" aria-label="Main"><p class="sidebar-title">General</p><a href="#" class="sidebar-item" aria-current="page"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 10.5 12 3l9 7.5V20a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z"/></svg><span class="sidebar-label">Home</span></a><a href="#" class="sidebar-item"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M22 12h-6l-2 3h-4l-2-3H2"/><path d="M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"/></svg><span class="sidebar-label">Inbox</span><span class="sidebar-badge">8</span></a><a href="#" class="sidebar-item"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 3v18h18"/><path d="m7 15 4-4 3 3 5-6"/></svg><span class="sidebar-label">Reports</span></a></nav><div class="sidebar-section"><p class="sidebar-title">Projects</p><details class="sidebar-group" open><summary class="sidebar-item"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/></svg><span class="sidebar-label">Website</span></summary><div><a href="#" class="sidebar-item"><span class="sidebar-label">Pages</span></a><a href="#" class="sidebar-item"><span class="sidebar-label">Deployments</span></a></div></details></div><div class="sidebar-footer"><a href="#" class="sidebar-item"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="3"/><path d="M12 2v3M12 19v3M4.9 4.9 7 7M17 17l2.1 2.1M2 12h3M19 12h3M4.9 19.1 7 17M17 7l2.1-2.1"/></svg><span class="sidebar-label">Settings</span></a></div></aside>Theme it with --seed on any ancestor, for example style="--seed: #0d9488", and force a scheme with class="dark" or class="light" on a wrapper.
Accessibility
- Built on
detailsandsummary, so it opens with Enter or Space and screen readers announce expanded and collapsed. A sharednamemakes a group exclusive. - Wrap navigation in
navwith anaria-labelwhen there is more than one on the page, and mark the current link witharia-current="page". - Every interactive part shows a visible focus ring with
:focus-visible, and tone colors pair with-foregroundtokens that keep text at 4.5:1 or better in light and dark mode.