Navigation and overlays
Command palette
A search box with grouped results and keyboard hints, shown in a top aligned modal dialog.
Example
<button type="button" commandfor="palette" command="show-modal" class="inline-flex items-center justify-center gap-2 rounded-lg border border-border bg-surface px-4 py-2 text-sm font-medium hover:bg-muted"><svg class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>Search<kbd class="ml-2 whitespace-nowrap rounded border border-border px-1.5 font-sans text-xs text-muted-foreground">Ctrl K</kbd></button><dialog id="palette" class="modal modal-top" aria-label="Command palette"><div class="command-palette"><label class="command-palette-search"><input class="command-palette-input" placeholder="Type a command or search" autofocus></label><div class="command-palette-list" role="listbox"><p class="command-palette-heading">Suggestions</p><a href="#" class="command-palette-item" role="option" aria-selected="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"/><path d="M14 3v6h6"/></svg>New document<span class="command-palette-shortcut"><kbd>Ctrl</kbd><kbd>N</kbd></span></a><a href="#" class="command-palette-item" role="option"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="9" cy="8" r="4"/><path d="M2 21a7 7 0 0 1 14 0M16 4a4 4 0 0 1 0 8M22 21a7 7 0 0 0-4-6.3"/></svg>Invite teammates</a><p class="command-palette-heading">Settings</p><a href="#" class="command-palette-item" role="option"><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="8" r="4"/><path d="M4 21a8 8 0 0 1 16 0"/></svg>Profile<span class="command-palette-shortcut"><kbd>Ctrl</kbd><kbd>P</kbd></span></a><a href="#" class="command-palette-item" role="option"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"/><path d="M10.3 21a1.94 1.94 0 0 0 3.4 0"/></svg>Notifications</a></div><div class="command-palette-footer"><span><kbd>Enter</kbd> to select</span><span><kbd>Esc</kbd> to close</span></div></div><form method="dialog" class="modal-backdrop"><button aria-label="Close">Close</button></form></dialog>Classes
9 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 command palette. On a <div> in the example. Sets transform, flex display, alignment, width, height and overflow, and --tone and --tone-fg.CSS |
|
| Part | Part of the command palette. On a <label> in the example. Sets flex display, alignment, gap, padding, border and generated content.CSS |
|
| Part | Part of the command palette. On an <input> in the example. Sets alignment, width, height, text size, background and text color.CSS |
|
| Part | Part of the command palette. On a <div> in the example. Sets alignment, overflow and padding.CSS |
|
| Part | Part of the command palette. On a <p> in the example. Sets padding, text size, font weight and text color.CSS |
|
| Part | Part of the command palette. On an <a> in the example. Sets flex display, alignment, gap, width, padding and corner radius.CSS |
|
| Part | Part of the command palette. On a <span> in the example. Sets inline-flex display, gap, margin, text size, text color and inline-grid display.CSS |
|
| Modifier | Modifier, combined with the command-palette class. Not used in the example above. Sets padding, text size, text style and text color.CSS |
|
| Part | Part of the command palette. On a <div> in the example. Sets inline-grid display, alignment, width, height, padding and text size.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">
<!-- Command palette: start from the base class, then add modifiers -->
<button type="button" commandfor="palette" command="show-modal" class="inline-flex items-center justify-center gap-2 rounded-lg border border-border bg-surface px-4 py-2 text-sm font-medium hover:bg-muted"><svg class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>Search<kbd class="ml-2 whitespace-nowrap rounded border border-border px-1.5 font-sans text-xs text-muted-foreground">Ctrl K</kbd></button><dialog id="palette" class="modal modal-top" aria-label="Command palette"><div class="command-palette"><label class="command-palette-search"><input class="command-palette-input" placeholder="Type a command or search" autofocus></label><div class="command-palette-list" role="listbox"><p class="command-palette-heading">Suggestions</p><a href="#" class="command-palette-item" role="option" aria-selected="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"/><path d="M14 3v6h6"/></svg>New document<span class="command-palette-shortcut"><kbd>Ctrl</kbd><kbd>N</kbd></span></a><a href="#" class="command-palette-item" role="option"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="9" cy="8" r="4"/><path d="M2 21a7 7 0 0 1 14 0M16 4a4 4 0 0 1 0 8M22 21a7 7 0 0 0-4-6.3"/></svg>Invite teammates</a><p class="command-palette-heading">Settings</p><a href="#" class="command-palette-item" role="option"><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="8" r="4"/><path d="M4 21a8 8 0 0 1 16 0"/></svg>Profile<span class="command-palette-shortcut"><kbd>Ctrl</kbd><kbd>P</kbd></span></a><a href="#" class="command-palette-item" role="option"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"/><path d="M10.3 21a1.94 1.94 0 0 0 3.4 0"/></svg>Notifications</a></div><div class="command-palette-footer"><span><kbd>Enter</kbd> to select</span><span><kbd>Esc</kbd> to close</span></div></div><form method="dialog" class="modal-backdrop"><button aria-label="Close">Close</button></form></dialog>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 the native
dialogelement. Opened withshowModal()(or a command button) it goes to the top layer, makes the rest of the page inert, closes with Escape and returns focus to the button that opened it. - Give every control a visible
labellinked withfor, or anaria-labelwhen the purpose is obvious from context. Link help and error text witharia-describedby; invalid styles use:user-invalid, so they appear only after the user interacts. - 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.