Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Textarea examples · Standard

Short Textarea for React

A compact textarea fixed at three rows tall.

Framework
UI library

When vertical space is tight, in a sidebar, a dense settings panel or a quick note, a Textarea three lines tall is enough. The Textarea normally grows with its content from a minimum height; here field-sizing-fixed turns that off, min-h-0 drops the minimum, and rows sets the height to three lines, scrolling past them.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

FAQ

Why does the short Textarea need field-sizing-fixed and min-h-0?

The Textarea has field-sizing-content, so in browsers that support it the height follows the text and rows is ignored, and min-h-16 keeps it at least that tall. field-sizing-fixed brings back the rows height and min-h-0 removes the minimum, so three rows means three lines everywhere.

What happens when users type more than three lines?

The Textarea keeps its height and scrolls, with a scrollbar once the text overflows. Keyboard and screen reader users can still reach every line. If it should grow instead, drop field-sizing-fixed and cap it with a max height such as max-h-40.

Can I adjust the rows to make it even more compact?

Yes, rows takes any number. Two rows still reads as a multi-line field; at one row, use an Input instead, which says single line to everyone.

Should I allow users to resize short textareas?

The browser's resize handle stays on by default, which helps people who type more than you planned for. Add resize-none if the layout around it must not move, or resize-y to allow height changes only.

When should I use a short textarea instead of a regular one?

For brief text in tight spaces: a note on a card, a reply in a side panel, a short description in a settings row. For long-form writing such as articles or support requests, give people the default height or let the field grow.

Are short textareas with scrolling accessible?

Yes. Scrolling inside the field is native: arrow keys move through every line and screen readers read the whole value, not just the visible part. Give it a label; this demo, with none visible, sets aria-label.