Navigation and overlays
Menu
A list of links or actions with titles, icons, shortcuts, an active item, disabled and danger states, nested submenus on <details> and a horizontal layout.
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 menu. On an <ul> in the example. Sets pointer cursor, hidden by default, flex display, alignment, gap and text size, and 5 custom properties.CSS |
|
| Modifier | Modifier, combined with the menu class. Not used in the example above. Sets flex display, alignment, gap, width, padding and corner radius.CSS |
|
| Part | Part of the menu. On a <li> in the example. Sets padding, text size, font weight, text style and text color.CSS |
|
| Part | Part of the menu. On an <a> in the example. Sets text color, font weight and background.CSS |
|
| Part | Part of the menu. On an <a> in the example. Sets opacity.CSS |
|
| Part | Part of the menu. On a <button> in the example. Sets text color and background.CSS |
|
| Part | Part of the menu. On a <li> in the example. Sets height, margin and background.CSS |
|
| Part | Part of the menu. On a <span> in the example. Sets margin, padding, text size, text style and text color.CSS |
|
| Modifier | Modifier, combined with the menu class. Not used in the example above. Sets alignment, gap, absolute position, offsets, stacking order and width.CSS |
|
| Size | Small size. Not used in the example above. Sets --menu-pad, --menu-fs and --menu-gap.CSS |
|
| Size | Large size. Not used in the example above. Sets --menu-pad, --menu-fs and --menu-gap.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">
<!-- Menu: start from the base class, then add modifiers -->
<ul class="menu w-64 rounded-xl border border-border bg-surface p-2"><li class="menu-title">Workspace</li><li><a href="#" class="menu-active"><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>Inbox<span class="menu-shortcut">12</span></a></li><li><a href="#"><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>Analytics</a></li><li><details open><summary><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>Projects</summary><ul><li><a href="#">Website</a></li><li><a href="#">Mobile app</a></li><li><a href="#" class="menu-disabled">Archived</a></li></ul></details></li><li class="menu-divider"></li><li><button type="button" class="menu-danger"><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 6h18M8 6V4h8v2M19 6l-1 14H6L5 6"/></svg>Sign out</button></li></ul>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. - Use
buttonfor actions andafor navigation. Icon only buttons need anaria-label; decorative icons carryaria-hidden="true". - 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.