Navigation and overlays
Navbar
A top bar with start, center and end slots, optional sticky and blurred glass styles and a <details> based mobile menu that replaces the links below the md breakpoint.
Example
Classes
12 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 navbar. On a <header> in the example. Sets stacking order, flex display, alignment, gap, height and padding.CSS |
|
| Part | Part of the navbar. On a <div> in the example. Sets flex display, alignment, gap and width.CSS |
|
| Modifier | Modifier, combined with the navbar class. On a <nav> in the example. Sets flex display, alignment and gap.CSS |
|
| Part | Part of the navbar. On a <div> in the example. Sets flex display, alignment, gap and width.CSS |
|
| Part | Part of the navbar. On an <a> in the example. Sets inline-flex display, alignment, gap, text size, font weight and text style.CSS |
|
| Modifier | Modifier, combined with the navbar class. On a <nav> in the example. Sets flex display, alignment, gap and hidden by default.CSS |
|
| Part | Part of the navbar. On an <a> in the example. Sets inline-flex display, alignment, gap, height, padding and corner radius.CSS |
|
| Modifier | Modifier, combined with the navbar class. On a <header> in the example. Sets sticky position and offsets.CSS |
|
| Modifier | Modifier, combined with the navbar class. On a <header> in the example. Sets background.CSS |
|
| Part | Part of the navbar. On a <details> in the example. Sets pointer cursor, hidden by default, opacity, transform and block display.CSS |
|
| Part | Part of the navbar. On a <summary> in the example. Sets grid display, alignment, width, height, corner radius and text color.CSS |
|
| Part | Part of the navbar. On a <nav> in the example. Sets absolute position, offsets, flex display, alignment, gap and height.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">
<!-- Navbar: start from the base class, then add modifiers -->
<header class="navbar navbar-sticky navbar-blur"><div class="navbar-start"><a href="#" class="navbar-brand"><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>Acme</a></div><nav class="navbar-center navbar-nav" aria-label="Main"><a href="#" class="navbar-link" aria-current="page">Product</a><a href="#" class="navbar-link">Pricing</a><a href="#" class="navbar-link">Docs</a><a href="#" class="navbar-link">Blog</a></nav><div class="navbar-end"><a href="#" class="navbar-link hidden sm:inline-flex">Sign in</a><a href="#" class="inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:opacity-90">Get started</a><details class="navbar-mobile"><summary class="navbar-burger" aria-label="Menu"></summary><nav class="navbar-mobile-panel" aria-label="Mobile"><a href="#" class="navbar-link" aria-current="page">Product</a><a href="#" class="navbar-link">Pricing</a><a href="#" class="navbar-link">Docs</a><a href="#" class="navbar-link">Blog</a></nav></details></div></header>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.