Components · Form Controls
Textarea
A field for longer text across several lines.
Component Workbench
Switch between the live interactive preview, syntax-highlighted implementation code, copyable AI coding agent prompt, and designer anatomy blueprint.
Textarea · Canonical Spec
<div class="as-form-field">
<label class="as-form-field__label" for="deploy-notes">Release Notes</label>
<div class="as-textarea-box">
<textarea class="as-textarea" id="deploy-notes" maxlength="300" placeholder="Enter notes..."></textarea>
<div class="as-textarea__footer">
<span class="as-textarea__counter">0 / 300</span>
</div>
</div>
</div> # Aster Component Implementation Prompt — Textarea
## 1. Component Purpose & Canonical Role
- **Component:** Textarea (`textarea`)
- **Category:** Form Controls
- **Native Element:** `<textarea>`
- **Summary:** A field for longer text across several lines.
- **When to Use:** When user input is expected to exceed a single line.
- **When Not to Use:** Single-line strings such as emails, slugs, or passwords (use Input).
## 2. Authoritative Repository Files
- **Component CSS:** `components/textarea/textarea.css`
- **Component Spec:** `docs/components/textarea.md`
- **Agent Contract:** `skills/using-aster-components/SKILL.md`
- **Compiled Bundle:** `dist/css/aster.css` and `dist/js/aster.js`
## 3. Canonical HTML Structure & Classes
```html
<div class="as-form-field">
<label class="as-form-field__label" for="deploy-notes">Release Notes</label>
<div class="as-textarea-box">
<textarea class="as-textarea" id="deploy-notes" maxlength="300" placeholder="Enter notes..."></textarea>
<div class="as-textarea__footer">
<span class="as-textarea__counter">0 / 300</span>
</div>
</div>
</div>
```
## 4. Measured Geometry
Measured from the rendered component when this page loads.
## 5. Non-Negotiable Aster Constraints
1. **Zero Primitive Color Leaks:** Bind colors strictly to `--as-semantic-color-*` custom properties. Never use `--as-color-primitive-*` or hardcoded hex values in component usage.
2. **Minimum 4px Radius Policy:** Never use `2px` border-radius. Use `--as-radius-sm` (`4px`), `--as-radius-md` (`8px`), `--as-radius-lg` (`12px`), or `--as-radius-full` (`9999px`).
3. **Single Standard Density Mode:** Compact mode (`data-density="compact"` / `.as-*--compact`) is permanently retired. Do not emit compact classes or attributes.
4. **WCAG 2.2 AA Accessibility:** Maintain >= 4.5:1 text contrast, >= 3:1 UI/border contrast, >= 24x24px interactive hit targets, and full keyboard operability (`Tab`, `Enter`, `Space`, `Escape`, Arrow keys).
## 6. Verification Commands
```bash
npm run test:components
npm run test:contrast
npm run test:browser
``` When to use it
Do
- Keep a visible label.
- Show a counter when there's a limit.
Don't
- Use it for short answers. Use Input instead.
- Cut text off silently at the limit.
Variants & States
Every option, rendered live with real styles.
Accessibility & Keyboard Interaction
Requirements for using this component accessibly, following the W3C ARIA Authoring Practices Guide.
| Interaction / Key | Behavior & Compliance Requirement |
|---|---|
Tab | Moves focus cleanly into and out of the textarea. |
| Explicit Label | Associated via <label for="id">. |
Tokens
Values update with the current theme.
| Role | Token | Current value |
|---|---|---|
| Surface Fill | --as-semantic-color-surface-card | |
| Border (Rest) | --as-semantic-color-border-strong | |
| Corner Radius | --as-radius-md |