Monsoon v0.2.0
Made by Alexandre Kohler Star

Forms

Input counter

A number input between decrease and increase buttons. The buttons need a few lines of JavaScript: call stepDown() and stepUp() on the input.

Forms2 classesNo JavaScriptLight and dark

Example

Full

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.

ClassTypeWhat it does
Base Base class of the input counter. On a <div> in the example. Sets flex display, alignment, width, inline-flex display, corner radius and margin.
CSS
.input-counter {
  display: inline-flex;
  width: auto;
}

.input-group > :hover, .input-counter > :hover {
  z-index: 1;
}
Part Part of the input counter. On a <button> in the example. Sets grid display, alignment, width, text size, text style and text color, and --_line and --_shadow.
CSS
.input-counter-button:hover {
  background-color: var(--surface-3);
}

.input-counter-button:disabled {
  cursor: not-allowed;
  opacity: var(--m-disabled-opacity);
}

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">

<!-- Input counter: start from the base class, then add modifiers -->
<div class="input-counter">
  <button type="button" class="input-counter-button" aria-label="Decrease">−</button>
  <input type="number" class="input" value="2" min="0" aria-label="Quantity">
  <button type="button" class="input-counter-button" aria-label="Increase">+</button>
</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

  • 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.
  • Use button for actions and a for navigation. Icon only buttons need an aria-label; decorative icons carry aria-hidden="true".
  • 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.