Monsoon v0.2.0
Made by Alexandre Kohler Star

Forms

Field

Label, control, hint and error message. The error shows on :user-invalid or aria-invalid, and field tones color the control and hint.

Forms9 classesNo JavaScriptLight and dark

Example

Full

Classes

9 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.

ClassTypeWhat it does
Base Base class of the field. On a <div> in the example. Sets grid display, gap, width, hidden by default, flex display and text color.
CSS
.field .error-text {
  display: none;
}

.field {
  display: grid;
  gap: .375rem;
  min-width: 0;
}
Modifier Modifier, combined with the field class. On a <label> in the example. Sets inline-flex display, alignment, gap, text size, font weight and text style.
CSS
.label:has(:disabled) {
  cursor: not-allowed;
  opacity: var(--m-disabled-opacity);
}

.label {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-size: .875rem;
  font-weight: 500;
  line-height: 1.25rem;
  color: var(--foreground);
}
Part Part of the field. Not used in the example above. Sets text size, font weight, text style and text color.
CSS
.label-text {
  font-size: .875rem;
  font-weight: 500;
  line-height: 1.25rem;
  color: var(--foreground);
}
Modifier Modifier, combined with the field class. On a <label> in the example. Sets generated content, margin and text color.
CSS
.label-required::after {
  content: "*";
  margin-inline-start: -.375rem;
  color: var(--danger);
}
Part Part of the field. On a <p> in the example. Sets text size, text style and text color.
CSS
.hint {
  font-size: .8125rem;
  line-height: 1.25rem;
  color: var(--muted-foreground);
}

.field-danger .hint {
  color: var(--danger);
}
Part Part of the field. On a <p> in the example. Sets flex display, alignment, gap, text size, text style and text color.
CSS
.error-text {
  display: flex;
  align-items: flex-start;
  gap: .375rem;
  font-size: .8125rem;
  line-height: 1.25rem;
  color: var(--danger);
}

.error-text::before {
  content: "";
  flex: none;
  width: 1rem;
  height: 1rem;
  margin-top: .125rem;
  background-color: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7.5v5M12 16.5h.01'/%3E%3C/svg%3E") center / contain no-repeat;
}
Tone Success tone. On a <div> in the example. Sets text color, and --field-border, --field-tone and --tone.
CSS
.field-success .hint {
  color: var(--success);
}

.input-success, .select-success, .textarea-success, .field-success {
  --field-border: var(--success);
  --field-tone: var(--success);
  --tone: var(--success);
}
Tone Warning tone. Not used in the example above. Sets text color, and --field-border, --field-tone and --tone.
CSS
.field-warning .hint {
  color: color-mix(in oklab, var(--warning), var(--foreground) 40%);
}

.input-warning, .select-warning, .textarea-warning, .field-warning {
  --field-border: var(--warning);
  --field-tone: var(--warning);
  --tone: var(--warning);
}
Tone Danger tone. Not used in the example above. Sets text color, and --field-border, --field-tone and --tone.
CSS
.field-danger .hint {
  color: var(--danger);
}

.input-danger, .select-danger, .textarea-danger, .field-danger {
  --field-border: var(--danger);
  --field-tone: var(--danger);
  --tone: var(--danger);
}

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.

index.html
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/monsooncss">

<!-- Field: start from the base class, then add modifiers -->
<div class="grid gap-4 max-w-sm">
  <div class="field">
    <label class="label label-required" for="f-email">Email</label>
    <input id="f-email" type="email" class="input" required placeholder="you@example.com">
    <p class="hint">We never share your email.</p>
    <p class="error-text">Enter a valid email address.</p>
  </div>
  <div class="field">
    <label class="label" for="f-user">Username</label>
    <input id="f-user" class="input" value="mo" aria-invalid="true" aria-describedby="f-user-error">
    <p class="error-text" id="f-user-error">Usernames need at least 3 characters.</p>
  </div>
  <div class="field field-success">
    <label class="label" for="f-handle">Handle</label>
<!-- 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 label linked with for, or an aria-label when the purpose is obvious from context. Link help and error text with aria-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 -foreground tokens that keep text at 4.5:1 or better in light and dark mode.

No recent searches

Try , , or .

Recent

Loading the search index

No results for ""

Check the spelling, or search a class name such as px-4.