Actions and feedback
Keyboard key
Keyboard keys and shortcuts in five sizes.
Example
<p class="flex flex-wrap items-center gap-1 text-sm">Press <kbd class="kbd">Ctrl</kbd> + <kbd class="kbd">K</kbd> to open the command menu.</p>
<div class="flex flex-wrap items-center gap-2 mt-3">
<kbd class="kbd kbd-xs">Esc</kbd>
<kbd class="kbd kbd-sm">Tab</kbd>
<kbd class="kbd kbd-md">Shift</kbd>
<kbd class="kbd kbd-lg">Enter</kbd>
<kbd class="kbd kbd-xl">Space</kbd>
</div>Classes
6 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 keyboard key. On a <kbd> in the example. Sets inline-flex display, alignment, width, height, padding and border, and --kbd-h and --kbd-fs.CSS |
|
| Size | Extra small size. On a <kbd> in the example. Sets --kbd-h and --kbd-fs.CSS |
|
| Size | Small size. On a <kbd> in the example. Sets --kbd-h and --kbd-fs.CSS |
|
| Size | Medium, the default size. On a <kbd> in the example. Sets --kbd-h and --kbd-fs.CSS |
|
| Size | Large size. On a <kbd> in the example. Sets --kbd-h and --kbd-fs.CSS |
|
| Size | Extra large size. On a <kbd> in the example. Sets --kbd-h and --kbd-fs.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">
<!-- Keyboard key: start from the base class, then add modifiers -->
<p class="flex flex-wrap items-center gap-1 text-sm">Press <kbd class="kbd">Ctrl</kbd> + <kbd class="kbd">K</kbd> to open the command menu.</p>
<div class="flex flex-wrap items-center gap-2 mt-3">
<kbd class="kbd kbd-xs">Esc</kbd>
<kbd class="kbd kbd-sm">Tab</kbd>
<kbd class="kbd kbd-md">Shift</kbd>
<kbd class="kbd kbd-lg">Enter</kbd>
<kbd class="kbd kbd-xl">Space</kbd>
</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 the
kbdelement for keys so the meaning survives without styles. - 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.