Playground

Textarea

A multi-line text field.

  • Built on native elements
  • Native <textarea>.
  • Inside a Field it is labelled and described automatically; invalid sets aria-invalid.
  • Styles in one file: 03-form-fields.css

Import

import '@monoline/css';
import {Textarea} from '@monoline/react';

Not installed yet? Pick a route.

Copies the source and its styles into your project.

npx monoline add textarea

Usage

import {Textarea} from '@monoline/react';

<div style={{maxWidth: 420}}>
  <Textarea aria-label="Notes" placeholder="What happened today?" />
</div>

Examples

Basic

Props

TextareaProps

PropTypeDefaultDescription
invalidboolean–Marks the control invalid (`aria-invalid`). A surrounding Field sets this from its `error`.

Data Attributes

State is exposed through attributes. Style it with these selectors, not with class toggles.

AttributeStylesheet
[aria-checked="true"]03-form-fields.css
[aria-invalid="true"]03-form-fields.css
[aria-pressed="true"]03-form-fields.css
[data-valid="true"]11-field-states.css

CSS classes

ClassStylesheet
.field03-form-fields.css
.field-hint03-form-fields.css
.input03-form-fields.css
.input-bare03-form-fields.css
.input-end03-form-fields.css
.input-lg03-form-fields.css
.input-sm03-form-fields.css
.input-wrap03-form-fields.css
.muted03-form-fields.css
.seg03-form-fields.css
.seg-opt03-form-fields.css
.select03-form-fields.css
.setting03-form-fields.css
.switch03-form-fields.css
.textarea03-form-fields.css
.field-error11-field-states.css
.field-ok11-field-states.css
.field-required11-field-states.css
.form-row11-field-states.css
.input11-field-states.css
.input-affix11-field-states.css
.input-group11-field-states.css
.select11-field-states.css
.textarea11-field-states.css

Customization

Style it with the kit's tokens in your own CSS, loaded after @monoline/css. Prefer the attributes above over extra classes. See Theming for every token.

app.css
.field {
  border-color: var(--accent);
}
.field[aria-checked="true"] {
  background: var(--wash);
}

Try the props

Change a prop and the component above updates; the code below is what you would write. To edit the code itself, use the Playground.

example.tsx
<Textarea aria-label="Message" placeholder="Tell us more" />

Accessibility

  • Native <textarea>.
  • Inside a Field it is labelled and described automatically; invalid sets aria-invalid.