Inputs · Counterstable
Counter
A small number badge that shows how many items sit behind a tab, nav item or filter, such as unread messages or pending runs. Not interactive. Value, max (99+ overflow), color, emphasis and size.
Preview
#previewSwitch color, emphasis, size and value. Show code opens the React and CSS below.
Inbox12
neutral · subtle · medium · value 12 · max 99
inbox-tab.tsx
import { Counter } from "@blade-ai/weft/components/counter";
export function InboxTab({ unread }: Props) {
return (
<button type="button" role="tab" aria-label={`Inbox, ${unread} unread`}>
Inbox
<Counter
value={unread}
max={99}
/>
</button>
);
}
// 12 renders as 12All states
#all-statesEvery colour and emphasis from the Counter spec. A counter has no hover, focus or pressed states.
12
neutral · subtle
12
neutral · intense
12
primary · subtle
12
primary · intense
12
positive · subtle
12
positive · intense
12
negative · subtle
12
negative · intense
12
notice · subtle
12
notice · intense
12
information · subtle
12
information · intense
777
Small · medium · large
9999+1,284
max 99 · 99 · 99+ · 1,284
0(hidden)
Zero · isHiddenWhenZero
Props
#propsOnly value is required. Anything marked UNDEFINED is an open decision.
Prop
Type
Default
Description
value *
number
—
The count to show. Whole number, 0 or more.
max
number
—
Upper limit. When value is above max, shows "{max}+", such as 99+. Without max the value is shown as-is.
color
"neutral" | "primary" | "positive" | "negative" | "notice" | "information"
"neutral"
Meaning of the count. Neutral for totals; notice and negative only when it needs attention.
emphasis
"subtle" | "intense"
"subtle"
Subtle tint or intense solid fill.
size
"small" | "medium" | "large"
"medium"
Height 16 / 20 / 24px. Match the parent: small in tabs, medium in nav items.
isHiddenWhenZero
boolean
false
Renders nothing when value is 0. Not in Blade; default false is proposed: UNDEFINED · needs decision.
accessibilityLabel
string
—
Spoken text when the parent label can't carry the count, such as "12 unread". Usually leave empty and name the parent instead.
testID
string
—
Test hook, rendered as data-testid.
Usage
#usageShort rules for using counters.
Do
Put the count in the parent's accessible name ("Inbox, 12 unread").
Use neutral · subtle for totals; colour only for counts that need attention.
Cap with max={99} in tabs and nav.
Group thousands with the locale separator.
Use Theme tokens only; check value text against its fill at 4.5:1.
Use small in mobile tab bars; the touch target belongs to the parent.
Don't
Don't make the counter focusable or clickable.
Don't put words, units or a leading "+" inside it; use Badge for status words.
Don't use a counter for "new" without a number; use Indicator.
Don't rely on colour alone to carry meaning.
Don't put aria-live on every counter.
Don't ship positive · intense in Dark until the 3.22:1 failure is decided.
Accessibility
#accessibilityA plain span with no role and no tabindex. The parent carries the accessible name.
Keyboard
Key
Action
Tab / Shift+Tab
Skips the counter; focus lands on the parent tab or nav item.
Arrow keys
Handled by the parent (Tabs, nav); unchanged by the counter.
Enter / Space
Activates the parent; the counter has no action.
Click
Hits the parent; the counter adds no handler and no extra target.
ARIA
Element
Role / attribute
When
span (counter)
role
none
span (counter)
tabindex
none (never focusable)
span (counter)
aria-hidden="true"
set by the app when the parent name already includes the count
span (counter)
aria-label
accessibilityLabel, only when the count is not in the parent name
parent
accessible name
"Inbox, 12 unread"
parent region
aria-live="polite"
only when the update matters; never on every tab counter
visually hidden text
text
"12 unread" when the parent label can't include the count
Agent Spec
#agent-specMachine-readable spec, tables (a)–(h). Same source as /specs/counter.json. Anything marked UNDEFINED needs a decision before it is built.
[ "isHiddenWhenZero default (false is proposed)", "Radius: square (--border-radius-none, Weft) or pill (Blade)", "positive · intense in Dark fails contrast at 3.22:1 (green-600 + white); proposed: green-700 fill in Dark" ]