Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Field examples · Text Areas

Textarea with Character Count Field for React

A bio textarea with a live count of characters used out of 500.

Framework
UI library

Show how much room is left while people type. The Bio Textarea caps input at 500 characters, and a FieldDescription under it shows the count, updated from the field's value.

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

Where does the character count come from?

FieldDescription prints the length of value, then the limit, as a count of characters. It starts at 0 because value starts empty.

What stops the bio at 500 characters?

The textarea's max length is 500, and rows is 4. The placeholder is Tell us about yourself.

How does the count update while typing?

value is the textarea's text, and FieldLabel names it Bio. Its htmlFor matches the control's id. Store the next text from onChange.

Where does the count sit?

The order is FieldLabel, Textarea, then FieldDescription. The count stays under the box while someone types.

Is the label beside the box?

No. orientation is unset, so Bio stays above the textarea. max-w-md caps the width.

What happens to the placeholder as the count changes?

The placeholder Tell us about yourself clears once someone types. The count under the box keeps updating from the length of value.