Forms
Search field
A search input with a leading icon and an optional keyboard shortcut hint.
Example
<label class="search-field max-w-sm">
<input type="search" class="input" placeholder="Search docs" aria-label="Search docs">
<kbd class="search-field-shortcut">/</kbd>
</label>Classes
2 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 search field. On a <label> in the example. Sets block display, generated content, absolute position, stacking order, offsets and width.CSS |
|
| Part | Part of the search field. On a <kbd> in the example. Sets absolute position, offsets, padding, text size, text style and text color.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">
<!-- Search field: start from the base class, then add modifiers -->
<label class="search-field max-w-sm">
<input type="search" class="input" placeholder="Search docs" aria-label="Search docs">
<kbd class="search-field-shortcut">/</kbd>
</label>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
- 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. - 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.