Forms · astro-ui · Textarea
TextareaJS
Multi-line input with counters, clear button, and resize control.
Textarea mirrors Input’s states and adds multi-line niceties: character counter, optional clear button, auto-grow bounds, and resize control. The core control is zero-JS; the extras are progressive enhancements — a tiny scoped script wires them and they degrade gracefully without it.
Features
- Input-matching variants and sizes
- showCount / counter character displays
- clearable — clear button appears while typing
- minRows / maxRows auto-grow
- resize control (none/vertical/horizontal/both)
Usage
---
import { Textarea, Label } from "astro-ui";
---
<Label for="bio">Bio</Label>
<Textarea id="bio" rows={4} maxlength={280} showCount clearable />Demos
Basic + counter + clear
0 / 280
<Textarea rows={4} maxlength={280} showCount clearable placeholder="Tell us about yourself" />Auto-grow
<Textarea minRows={2} maxRows={5} placeholder="Grows with input" />Resize
<Textarea resize="vertical" rows={2} />API
Props
| Prop | Type | Default | Description |
|---|---|---|---|
rows | number | 4 | Visible rows. |
maxlength / minlength | number | — | Length bounds. |
showCount / counter | boolean | false | Character-count readout (aliases). |
clearable | boolean | false | Clear button, visible with text. |
minRows / maxRows | number | — | Auto-grow bounds; sets resize to none. |
resize | "none" | "vertical" | "horizontal" | "both" | "vertical" | Resize axis. |
invalid | boolean | false | Validation state. |
size | "xs" | "sm" | "md" | "lg" | "xl" | "md" | Scale. |
variant | "inherit" | "primary" | … | "info" | "inherit" | Border color. |
class | string | — | Merged via cn(); Tailwind classes welcome. |
id | string | — | Element id. |
ariaLabel | string | — | Accessible name. |
Accessibility
Implemented accessibility features — semantics, ARIA wiring, and keyboard behavior that ship with the component.
- Native textarea semantics; hint/error text via
aria-describedby aria-invalidfor validation state
FAQ
showCount vs counter?
They are aliases — either renders the count readout ("n / maxlength" when a cap is set). Pick the name that reads best in your markup.
Changelog
Version history mentioning Textarea.
v0.1.0 — 2026-11-11
added
- Forms (18): Autocomplete, Combobox, Label, Field, Input, InputGroup, Textarea, Select, Checkbox, Radio, Switch, Toggle, ToggleGroup, RadioGroup, Rating, Slider, DatePicker, TimePicker.
- Shared
--ui-control-*scale (height, inline padding, radius) used by Button, Input, Select, Textarea, and InputGroup so controls align on a row.