Navigation and overlays
Table of contents
An on this page list with nested levels and an active marker on the rail, set with .toc-active or aria-current.
Example
<nav aria-labelledby="toc-title" class="w-56"><p id="toc-title" class="toc-title">On this page</p><ul class="toc"><li><a href="#install" class="toc-active">Installation</a></li><li><a href="#usage">Usage</a><ul><li><a href="#cdn">From a CDN</a></li><li><a href="#npm">From npm</a></li></ul></li><li><a href="#theming">Theming</a></li><li><a href="#faq">FAQ</a></li></ul></nav>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 table of contents. On an <ul> in the example. Sets flex display, alignment, text size, border, block display and margin, and --tone and --tone-fg.CSS |
|
| Part | Part of the table of contents. On a <p> in the example. Sets margin, text size, font weight and text color.CSS |
|
| Modifier | Modifier, combined with the toc class. Not used in the example above. Sets block display, margin, padding, text style, text color and border.CSS |
|
| Part | Part of the table of contents. On an <a> in the example. Sets font weight, text color and border.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">
<!-- Table of contents: start from the base class, then add modifiers -->
<nav aria-labelledby="toc-title" class="w-56"><p id="toc-title" class="toc-title">On this page</p><ul class="toc"><li><a href="#install" class="toc-active">Installation</a></li><li><a href="#usage">Usage</a><ul><li><a href="#cdn">From a CDN</a></li><li><a href="#npm">From npm</a></li></ul></li><li><a href="#theming">Theming</a></li><li><a href="#faq">FAQ</a></li></ul></nav>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
- 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.