Skip to content
IndexRequest a UIAboutContact

Character Counter & Limit

A textarea with a progress ring that turns amber near the limit and red when over, without blocking typing.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI CODING TOOL
Clean UI design of a compose box: a white rounded textarea with a short sentence typed in, below it on the right a small circular progress ring in amber showing 12 characters left, a grey Post button next to it, a thin border, light theme, flat modern style. Variants: ring green with plenty of room, and red with the text -8 and the Post button disabled. Negative: heavy borders, gradients, emoji clutter, text errors. Reduced motion: static design.

About this pattern

Definition

A counter tells people how much room is left. A soft limit lets them keep typing past the maximum, so pasted text is never silently cut off, while the counter shows how much to trim and the submit button waits until the text fits.

Purpose & UX principles

  • Show remaining characters only when it matters, for example in the last 20 percent.
  • Use colour and text together: amber at 80 percent, red over the limit with the negative number.
  • Do not truncate pasted text; show the overflow and let the user edit.

Interaction states

  • A textarea with a 120 character limit, a ring, a counter and a Post button.

Motion specification

  • The ring arc updates as you type with a 100ms ease.
  • Reduced motion: no easing.

Responsive behaviour

  • Announce the remaining count at a few thresholds, not on every keystroke.
  • Count characters the way the server does, including emoji and line breaks.

Code

HTML
<div class="bx"><label class="rw" for="ta">What is on your mind?</label><textarea id="ta" rows="4" placeholder="Write something short"></textarea><div class="ft"><span id="msg" class="out"></span><svg class="rg" viewBox="0 0 36 36" width="30" height="30" aria-hidden="true"><circle cx="18" cy="18" r="15" fill="none" stroke="#e7e7e4" stroke-width="3"/><circle id="arc" cx="18" cy="18" r="15" fill="none" stroke="#2a9d62" stroke-width="3" stroke-linecap="round" stroke-dasharray="94.25" stroke-dashoffset="94.25" transform="rotate(-90 18 18)"/></svg><b id="n"></b><button class="mini" id="po" type="button" disabled>Post</button></div><span class="sr-only" id="sr" role="status"></span></div>

Related patterns

Text Input

↗
Text InputInputs & Forms

Validation States

↗
Validation StatesInputs & Forms

Tag Input with Chips

↗
Tag Input with ChipsInputs & Forms