Form character count

Shows how many characters remain before, or exceed, an input limit.

On this page

This docs is LLM-friendly and available as clean Markdown.

Supported browser agents can also use WebMCP to search, read, and open these docs. Learn more

Usage

import { GlFormCharacterCount } from "gitlab-ui-react/form-character-count";
<GlFormCharacterCount
  countTextId="summary-count"
  limit={100}
  overLimitText="1 character over limit."
  remainingCountText="25 characters remaining."
  value="Lorem ipsum" />

Default

Use a character count when a text field has a meaningful limit. The visible count updates immediately, while its polite live region is debounced to avoid excessive announcements.

Input character count
40 characters remaining.

Accessibility

  • Connect the input to countTextId with aria-describedby.
  • Provide localized remainingCountText and overLimitText; include the current count in each value.
  • Do not use the counter as the only validation feedback when exceeding the limit prevents submission.

API

GlFormCharacterCount forwards supported attributes to its root <div> and does not accept unnamed children.

Prop Description Default
countTextId Sets the polite live region ID referenced by the input.
limit Sets the character limit.
value Supplies the current input value. ""
remainingCountText Provides localized text shown at or below the limit.
overLimitText Provides localized text shown above the limit.