Skip to content

CharacterCount

CharacterCount offers immediate validation for text fields with character limits.
  • Use CharacterCount when enforcing character limits in order to provide instant user feedback
React props
NameTypeDefaultDescription
length  RequirednumberThe amount of characters currently in the associated field.
maxLength  RequirednumberThe maximum amount of characters allowed in the associated field.

The following testing snippet(s) offer suggestions for testing the component using React Testing Library with occasional help from Jest.

render(<CharacterCount length={5} maxLength={32} />);
const characterCount = screen.getByText('5 / 32');
expect(characterCount).toBeInTheDocument();