Textarea
Multi-line text that grows smoothly with what you write between a minimum and maximum number of rows, with counters, validation and a submit shortcut.
- Form components
- 1 parts
- 7 examples
- vs shadcn/ui
@base-ui/react
See it in a real product: Image Studio, Memory, Model Compare, and 9 more
View blockGrows with your text, then scrolls.
pnpm dlx shadcn@latest add https://hextaui.com/r/textarea.jsonAdds the component, the HextaUI theme tokens and any HextaUI components it depends on.
Add the theme tokens to your global CSS, if you haven’t yet.
Install the dependencies.
pnpm add @base-ui/react class-variance-authority cnCopy and paste the following code into your project.
components/ui/textarea.tsx components/ui/input.tsx components/ui/number-flow.tsx lib/motion.ts Update the import paths to match your project setup.
The box grows with your text, easing to each new line instead of jumping, from minRows up to maxRows, then scrolls. Typing is never delayed by the animation.
submitOnShortcut submits the form with ⌘ + Enter or Ctrl + Enter. Enter on its own still starts a new line.
With maxLength inside a Field, FieldCounter counts as you type and nudges when you hit the limit.
minRows and maxRows set where growing starts and stops.
autoResize={false} keeps a fixed height with a vertical resize handle.
Disabled, read-only and invalid. Invalid textareas shake when a form submit fails.
Text, placeholder and caret follow the reading direction.
| Key | Action |
|---|---|
| Enter | Starts a new line. |
| ⌘Enter | Submits the form, with submitOnShortcut. Ctrl + Enter on Windows and Linux. |
- Label it with
FieldLabeloraria-label. - On touch screens the text is at least 16px, so iOS doesn't zoom in when it's focused.
- The shortcut waits while an input method is composing, so confirming a Japanese or Chinese word never sends the message.
- With reduced motion, the box resizes instantly.
| Prop | Type | Default |
|---|---|---|
autoResizeGrow with the text instead of a fixed height. | boolean | true |
minRows | number | 3 |
maxRows | number | 10 |
submitOnShortcutSubmit the parent form with ⌘/Ctrl + Enter. | boolean | false |
shakeShake when a form submit finds it invalid. | boolean | true |
| Attribute | Description |
|---|---|
data-slot="textarea" | The textarea. |
data-autoresize | Present when it grows with its text. |
--textarea-min-rows / --textarea-max-rows | Set from minRows and maxRows. |
- InputA text input with three sizes, invalid and read-only states, native validation styling and a 16px touch font so phones never zoom in.
- useAutosizeGrows a textarea with what you write between its minimum and maximum height, animating each change without ever touching the text.
- useComposedRefKeeps a ref to your own element while still forwarding it to whatever ref the parent passed in.
- useInvalidShakeShakes a form control when a submit attempt finds it invalid, and never while someone is still typing.
- CalendarA date grid for single, range and multiple selection, with sliding months, range previews and touch-sized days.
- CheckboxA checkbox whose check draws in, with indeterminate parents, groups and labels that share its hover.
Used in Pro blocks
Blocks that build on Textarea.
Every block comes with HextaUI Pro, and Prompt Input is free.