Skip to content
Haze UI

Textarea

Multi-line text field with the same finish as the input, resizable vertically or growing with its content.

pnpm dlx shadcn@latest add @haze/textarea
Open preview in a new tab
Liveno JavaScript

When to use

  • Messages, comments, bios and release notes that run past one line
  • Contact forms where the user explains a problem in their own words

When not to use

  • Short single-line values such as an email; use input
  • Rich text with formatting, which needs an editor

Installation

Add the Haze registry to components.json once, then install Textarea with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.

pnpm dlx shadcn@latest add @haze/textarea
First time? Registry and theme setup

1. Add to components.json:

{
  "registries": {
    "@haze": "http://localhost:4329/r/{name}.json"
  }
}

2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";

API reference

PropTypeDefaultDescription
id*string–Element id; reference it from a label or Field.
namestringidForm field name.
rowsnumber4Visible lines before the user resizes it.
placeholderstring–Example text shown while empty.
autoGrowbooleanfalseGrows the box with its content up to 15 rem where the browser supports field-sizing, and turns off manual resizing.
requiredboolean–Marks the field required.
classstring–Extra classes.
...restattributes–Any other textarea attribute: disabled, maxlength, aria-invalid, aria-describedby.

Keyboard interactions

Enter
Inserts a new line instead of submitting the form
Tab
Moves focus out of the field

Accessibility

  • With autoGrow the box has no resize handle and stops growing at 15 rem, then scrolls; browsers without field-sizing keep the fixed rows height.
  • Resizing is limited to the vertical axis so a dragged box cannot push the form past a 320 px viewport.
  • The component renders no label; pair it with Field or a label whose for matches the id.
  • aria-invalid turns the border destructive, but also add an error message so the state is not shown by color alone.

Notes for AI

Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.

  • Install and use

    Install the Haze UI component "Textarea" with `npx shadcn@latest add @haze/textarea`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import Textarea from "@/components/haze/ui/textarea.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/textarea.md

  • Customize with real content

    Adapt the Haze textarea ui for our product. Replace the demo values of these props with our real content: id, name, rows, placeholder, autoGrow, required, class, ...rest. Keep the layout, the heading level rules and these accessibility details: With autoGrow the box has no resize handle and stops growing at 15 rem, then scrolls; browsers without field-sizing keep the fixed rows height. Resizing is limited to the vertical axis so a dragged box cannot push the form past a 320 px viewport. The component renders no label; pair it with Field or a label whose for matches the id. aria-invalid turns the border destructive, but also add an error message so the state is not shown by color alone. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using textarea, check it fits: use it when messages, comments, bios and release notes that run past one line; contact forms where the user explains a problem in their own words. Avoid it when short single-line values such as an email; use input; rich text with formatting, which needs an editor. Alternatives: @haze/input, @haze/field.

Dependencies

  • @haze/utils
  • @haze/theme (one-time setup)

Source · Original Haze UI work.

Catalog

↑↓ moveEnter openEsc close

Keyboard shortcuts

CtrlK
Command palette
/
Focus search
←↑→↓
Move between cards
jk
Next / previous card
ci
Copy code / install command (detail page)
[]
Previous / next entry
?
This help
Esc
Close dialog