Skip to content
v0.2.10

CharacterCount

Supporting character or remaining-length feedback with an explicit over-limit message.

Preview
24 / 40

Use CharacterCount

CharacterCount is a named export of @flood-md/react. Connect the package once, then import what you use.

First time here? Connect Flood
Example import style
character-count.tsxTSX
"use client";

import { FloodRoot, CharacterCount } from "@flood-md/react";
import "@flood-md/react/styles.css";

export function Example() {
  return (
    <FloodRoot>
      <CharacterCount value="Make room for a clear idea." max={80} htmlFor="project-note" />
    </FloodRoot>
  );
}

Design notes

  • Pass text through value or supply an explicit nonnegative integer count for a host-defined counting rule. The default text count uses Unicode code points, not UTF-16 code units or grapheme clusters. max is advisory and does not truncate or validate an editor.
  • mode remaining displays max minus count; count displays the current count and optional limit. An over-limit message is visible in addition to its semantic color. Translate label/overLimitLabel; lang formats the number.
  • Use htmlFor to associate supporting output with its editor and aria-describedby on the editor when appropriate. Live announcements default off to avoid announcing every keystroke; the host may opt into aria-live. Available in 0.2.5.

API reference

PropValuesDefault
valuestring—
countnumber—
maxnumber—
mode"count" | "remaining""count"
labelstring"Characters"
overLimitLabelstring"Over limit"
htmlForstring—
formstring—
Native HTML propsHTMLAttributes<HTMLOutputElement>Forwarded
View TypeScript source