Data display
Counter
Small count pill used in tabs, buttons and cells.
import { Counter } from "datui";Playground
8
<Counter variant="primary" appearance="accent" size="m">8</Counter>Examples
Variants
121212123
121212123
121212123
121212123
Accessibility
- Plain text with no role; add context such as visually hidden "unread" next to it.
- Renders nothing when children are empty.
API
Counter
Small count pill, e.g. unread items. Renders nothing without children. The number alone has no context for screen readers — add visually hidden text such as "unread" next to it.
| Prop | Type | Default | Description |
|---|---|---|---|
| appearance | "custom" | "accent" | "negative" | "positive" | "neutral" | "accent" | |
| className | string | — | |
| color | string | — | Any CSS color; used when `appearance="custom"`. Set `--dt-counter-foreground` for the text on filled custom counters (and the pill of `contrast` ones); it defaults to white. Pick values with 4.5:1 contrast per theme. |
| size | "s" | "m" | "m" | |
| variant | "inherit" | "primary" | "tertiary" | "contrast" | "primary" | `primary` filled, `contrast` inverted pill for colored surfaces, `tertiary` text only, `inherit` tinted with the current color. |