# CharacterCount

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

Connect Flood once using [the installation guide](https://flood.md/docs/installation). Then import the components you use; no per-component add command is needed.

## Example

```tsx
"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

| Prop | Values | Default |
| --- | --- | --- |
| `value` | `string` | `—` |
| `count` | `number` | `—` |
| `max` | `number` | `—` |
| `mode` | `"count" \| "remaining"` | `"count"` |
| `label` | `string` | `"Characters"` |
| `overLimitLabel` | `string` | `"Over limit"` |
| `htmlFor` | `string` | `—` |
| `form` | `string` | `—` |
| `Native HTML props` | `HTMLAttributes<HTMLOutputElement>` | `Forwarded` |
