U.S. flagA digital services project by Flexion

Character Count

formUSWDS-derivedinteractive

Attaches to a textarea or text input and shows remaining characters.

Reference: USWDS documentation ↗

Variants

Default Character Count

100 characters allowed

Required Character Count

200 characters allowed

Contract

Class mapping

USWDSFlexNotes
usa-character-count<flex-character-count> (custom element)Container element with data-maxlength attribute
usa-character-count__status.flex-character-count__messageRemaining/over-limit message element
usa-character-count__status--invalid[data-state="error"]Over-limit error state

Verified properties

font-sizefont-weightdisplaypadding-top

Intentional differences

color: ours = var(--flex-color-error), USWDS = #b50909

We use our error design token (red-warm-vivid-50) for consistency; USWDS uses a hardcoded red-vivid-60

Behavior promises

  • ✓ Initial message shows total characters allowed
  • ✓ Typing updates remaining count
  • ✓ Over-limit shows error state with count over

Source CSS