Navigation and overlays
Context menu
The compact look of a desktop context menu, with labels, separators, shortcuts and a filled highlight. Pair it with a popover to show it.
Example
Classes
4 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 context menu. On a <div> in the example. Sets flex display, alignment, width, padding, text size and background, and --tone and --tone-fg.CSS |
|
| Part | Part of the context menu. On a <div> in the example. Sets padding, text size, font weight and text color.CSS |
|
| Part | Part of the context menu. On a <div> in the example. Sets height, margin and background.CSS |
|
| Part | Part of the context menu. On a <span> in the example. Sets margin, padding, text size, text style and opacity.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">
<!-- Context menu: start from the base class, then add modifiers -->
<div class="context-menu w-56" role="menu" aria-label="Edit"><button type="button" role="menuitem">Undo<span class="context-menu-shortcut">Ctrl Z</span></button><button type="button" role="menuitem" disabled>Redo<span class="context-menu-shortcut">Ctrl Y</span></button><div class="context-menu-separator" role="separator"></div><div class="context-menu-label">Clipboard</div><button type="button" role="menuitem">Cut<span class="context-menu-shortcut">Ctrl X</span></button><button type="button" role="menuitem">Copy<span class="context-menu-shortcut">Ctrl C</span></button><button type="button" role="menuitem">Paste<span class="context-menu-shortcut">Ctrl V</span></button></div>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
- 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.