Monsoon v0.2.0
Made by Alexandre Kohler Star

Interactive

Textarea autosize

Grows the textarea with its content. Browsers with CSS field-sizing do it natively; the script measures the others. max-height still caps it. Needs monsoon.js.

Interactive1 classesNeeds monsoon.jsLight and dark

Needs monsoon.js. The styles work on their own, and the behavior comes from the optional interactive layer: add <script src="https://cdn.jsdelivr.net/npm/monsooncss/dist/monsoon.js" defer></script> or import 'monsooncss/js'. See the interactive layer.

Example

Full

JavaScript API

Attribute

data-m-autosize

Options

OptionDescription
rows sets the starting height, max-height the limit

Methods

MethodDescription

Events

EventDescription

Classes

1 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 textarea autosize. On a <textarea> in the example. Sets block display, width, height, padding, text size and text style, and 9 custom properties.
CSS
.input,
.select,
.textarea,
.file-input,
.color-input,
.otp-input,
.otp-field {
  --tone: var(--field-tone, var(--ring));
}

.input:read-only:not(:disabled), .textarea:read-only:not(:disabled) {
  background-color: var(--surface-2);
  box-shadow: none;
}

Usage

The styles ship inside the same stylesheet as the utilities, and the behavior comes from the optional monsoon.js script, which enhances any element with a matching data-m attribute, including markup added later.

index.html
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/monsooncss">
<script src="https://cdn.jsdelivr.net/npm/monsooncss/dist/monsoon.js" defer></script>

<!-- Textarea autosize: start from the base class, then add modifiers -->
<textarea class="textarea max-w-md max-h-64" rows="2" data-m-autosize aria-label="Message">Write as much as you like: this box grows line by line, then scrolls once it reaches its maximum height.</textarea>

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.