Skip to content

Textareas

Multi-line text fields with auto-resize and validation.


Setup

Textarea styles are included in Manifest CSS or the standalone inputs stylesheet. Both reference theme variables.

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/mnfst@latest/lib/manifest.min.css" />

Default


<textarea placeholder="Type here"></textarea>

Utilities

Textareas accept Manifest utility classes, which can be stacked in any combination.

Colors


<!-- Brand variant -->
<textarea class="brand" placeholder="Brand"></textarea>

<!-- Accent variant -->
<textarea class="accent" placeholder="Accent"></textarea>

<!-- Positive variant -->
<textarea class="positive" placeholder="Positive"></textarea>

<!-- Negative variant -->
<textarea class="negative" placeholder="Negative"></textarea>

Size


<!-- Small variant -->
<textarea class="sm" placeholder="Small"></textarea>

<!-- Large variant -->
<textarea class="lg" placeholder="Large"></textarea>

Appearance


<!-- No background until hover -->
<textarea class="ghost" placeholder="Ghost"></textarea>

<!-- Border included -->
<textarea class="outlined" placeholder="Outlined"></textarea>

<!-- No background at all -->
<textarea class="transparent" placeholder="Transparent"></textarea>

Resizing

Drag Handle

The CSS resize property or Tailwind's resize utility can be used to control the textarea's resizing behavior with a manual drag handle.


<textarea placeholder="Resize in any direction" class="resize"></textarea>

Automatic

The CSS property field-sizing: content or Tailwind's field-sizing-content utility allow a textarea to auto-resize from its minimum height to fit all content.


<textarea placeholder="Type to resize" class="field-sizing-content"></textarea>

If a resize drag handle is applied and interacted with, the manually-set height will override automatic resizing.


Labels

Placing the textarea and text inside a <label> automatically stacks them with spacing.


<label>
    Message
    <textarea placeholder="Enter your message"></textarea>
</label>

To horizontally inline the label text with the textarea, place the text in a <data> element. This is used as a CSS hook with no semantic impact.


<label>
    <data>Message</data>
    <textarea placeholder="Enter your message"></textarea>
</label>

Validation

Textareas support native HTML5 validation through required, minlength, and maxlength attributes. Invalid fields get a ring in the negative colour once the user has engaged with them. Tint the invalid and valid states further with Tailwind pseudo-class variants.


<textarea required minlength="10"
    class="user-invalid:negative user-valid:positive"></textarea>

Prefer user-invalid: and user-valid: over the unprefixed invalid: and valid:. They wait until the user has actually engaged with the field. See forms for the full variant reference and inline-message patterns.


Styles

Theme

Default textareas use the following theme variables:

Variable Purpose
--color-field-surface Textarea background color
--color-field-surface-hover Textarea hover/active background color
--color-field-inverse Text and selection highlight color
--spacing-field-padding Padding for textarea content
--radius Border radius for textarea corners
--transition Transition for interactive states

Customization

Modify base textarea styles with custom CSS for the textarea selector. Overriding the field theme variables keeps both color modes working.


textarea {
    --color-field-surface: color-mix(in oklch, var(--color-brand-surface) 12%, transparent);
    --color-field-surface-hover: color-mix(in oklch, var(--color-brand-surface) 20%, transparent);
    --color-field-inverse: var(--color-brand-content);
    border: 1px solid var(--color-brand-surface);
    border-radius: 1rem;
}