Forms
Form layout
A form stack, responsive rows of fields and an actions bar.
Example
<form class="form max-w-md">
<div class="form-row">
<div class="field">
<label class="label" for="fl-first">First name</label>
<input id="fl-first" class="input" autocomplete="given-name">
</div>
<div class="field">
<label class="label" for="fl-last">Last name</label>
<input id="fl-last" class="input" autocomplete="family-name">
</div>
</div>
<div class="form-actions">
<button type="reset" class="inline-flex items-center rounded-md px-4 py-2 text-sm font-medium border border-border">Cancel</button>
<button type="submit" class="inline-flex items-center rounded-md px-4 py-2 text-sm font-medium bg-primary text-primary-foreground">Save</button>
</div>
</form>Classes
3 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 form layout. On a <form> in the example. Sets grid display and gap.CSS |
|
| Part | Part of the form layout. On a <div> in the example. Sets grid display, grid tracks and gap.CSS |
|
| Part | Part of the form layout. On a <div> in the example. Sets flex display, alignment, gap and padding.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">
<!-- Form layout: start from the base class, then add modifiers -->
<form class="form max-w-md">
<div class="form-row">
<div class="field">
<label class="label" for="fl-first">First name</label>
<input id="fl-first" class="input" autocomplete="given-name">
</div>
<div class="field">
<label class="label" for="fl-last">Last name</label>
<input id="fl-last" class="input" autocomplete="family-name">
</div>
</div>
<div class="form-actions">
<button type="reset" class="inline-flex items-center rounded-md px-4 py-2 text-sm font-medium border border-border">Cancel</button>
<button type="submit" class="inline-flex items-center rounded-md px-4 py-2 text-sm font-medium bg-primary text-primary-foreground">Save</button>
<!-- the full example is in the Code tab above -->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. - 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.