Weftv0.4.0
GitHubFigma
Blade AI
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

#preview

Switch color, emphasis, size and value. Show code opens the React and CSS below.

Inbox
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 12

All states

#all-states

Every colour and emphasis from the Counter spec. A counter has no hover, focus or pressed states.

Counter · 12 colour and emphasis combinations · size medium · no interaction states
neutral · subtle
neutral · intense
12
primary · subtle
12
primary · intense
positive · subtle
positive · intense
negative · subtle
negative · intense
notice · subtle
notice · intense
information · subtle
information · intense
Small · medium · large
max 99 · 99 · 99+ · 1,284
(hidden)
Zero · isHiddenWhenZero

Props

#props

Only 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

#usage

Short 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

#accessibility

A 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-spec

Machine-readable spec, tables (a)–(h). Same source as /specs/counter.json. Anything marked UNDEFINED needs a decision before it is built.

/specs/counter.json·component: "Counter"·package: "@blade-ai/weft"·updated 2026-11-24
[
  "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"
]