Navigation and overlays
Drawer dialog
A modal side panel built on <dialog>, opened with command="show-modal" and closed with command="close" or a click outside (closedby="any"). Slides in from any edge.
Example
<button type="button" commandfor="cart-drawer" command="show-modal" 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">Open cart</button><dialog id="cart-drawer" class="drawer-dialog drawer-end" closedby="any" aria-labelledby="cart-title"><h2 id="cart-title" class="text-lg font-semibold">Your cart</h2><button type="button" commandfor="cart-drawer" command="close" class="modal-close" aria-label="Close"></button><ul class="flex flex-col gap-3 text-sm"><li class="flex justify-between"><span>Linen shirt</span><span class="font-medium">$48</span></li><li class="flex justify-between"><span>Canvas tote</span><span class="font-medium">$22</span></li></ul><button type="button" 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 mt-auto w-full">Checkout</button></dialog>Classes
5 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 drawer dialog. On a <dialog> in the example. Sets overflow, flex display, alignment, gap, width and height, and 8 custom properties.CSS |
|
| Part | Part of the drawer dialog. Not used in the example above. Sets 4 custom properties.CSS |
|
| Modifier | Modifier, combined with the drawer-dialog class. On a <dialog> in the example. Sets 4 custom properties.CSS |
|
| Part | Part of the drawer dialog. Not used in the example above. Sets 7 custom properties.CSS |
|
| Part | Part of the drawer dialog. Not used in the example above. Sets 7 custom properties.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">
<!-- Drawer dialog: start from the base class, then add modifiers -->
<button type="button" commandfor="cart-drawer" command="show-modal" 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">Open cart</button><dialog id="cart-drawer" class="drawer-dialog drawer-end" closedby="any" aria-labelledby="cart-title"><h2 id="cart-title" class="text-lg font-semibold">Your cart</h2><button type="button" commandfor="cart-drawer" command="close" class="modal-close" aria-label="Close"></button><ul class="flex flex-col gap-3 text-sm"><li class="flex justify-between"><span>Linen shirt</span><span class="font-medium">$48</span></li><li class="flex justify-between"><span>Canvas tote</span><span class="font-medium">$22</span></li></ul><button type="button" 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 mt-auto w-full">Checkout</button></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. - 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.