Skip to content

shadcn.io is an independent project built on shadcn/ui

Free

Textarea with Character Count Field for Svelte

A four-row Bio box, placeholder Tell us about yourself, stopped at 500 characters, with a count that starts at 0/500.

UI library: Ark UI

Bio sits above a four-row box. The placeholder is Tell us about yourself... The box stops at 500 characters. Under it, the count starts at 0/500 characters and follows what was typed.

Save it for a bio or caption with a hard limit. The same limit on one line is an Input. On Svelte, Ark UI does not keep this count.

Preview

Preview width

Installation

MCP · Pro
Make your AI a shadcn expert
Your agent installs components, builds pages and restyles your app from one prompt, in Claude Code, Cursor or VS Code.
Part of Pro

Anatomy

Field anatomy: root, label, input, description, error

Usage

<Field class="max-w-md"><FieldLabel>Bio</FieldLabel><Textarea maxlength={MAX_LENGTH} oninput={handleChange} placeholder="Tell us about yourself..." rows={4} value={value} /><FieldDescription>{value.length}/{MAX_LENGTH} characters</FieldDescription></Field>

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. Field connects the two for you, with no ids to write. Store the next text from oninput.

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.

API Reference

Field

No extra props in this demo. The rest is on the Field page.

Textarea

Sets maxlength={MAX_LENGTH}, oninput={handleChange}, placeholder="Tell us about yourself...", rows={4} and value={value}. The rest is on the Textarea page.