{
  "component": "Counter",
  "package": "@blade-ai/weft",
  "status": "stable",
  "version": "0.1.0",
  "updated": "2026-11-24",
  "import": "import { Counter } from \"@blade-ai/weft/components/counter\";",
  "docs": "/components/counter",
  "description": "A small number that sits inline after a parent's label (tabs, nav items, filters). It has no states and is never focusable; the parent carries the accessible name.",
  "props": [
    {
      "name": "value",
      "type": "number",
      "default": null,
      "required": true,
      "description": "The count to show. Whole number, 0 or more."
    },
    {
      "name": "max",
      "type": "number",
      "default": null,
      "required": false,
      "description": "Upper limit. When value is above max, shows \"{max}+\", such as 99+. Without max the value is shown as-is."
    },
    {
      "name": "color",
      "type": "\"neutral\" | \"primary\" | \"positive\" | \"negative\" | \"notice\" | \"information\"",
      "default": "neutral",
      "required": false,
      "description": "Meaning of the count. Neutral for totals; notice and negative only when it needs attention."
    },
    {
      "name": "emphasis",
      "type": "\"subtle\" | \"intense\"",
      "default": "subtle",
      "required": false,
      "description": "Subtle tint or intense solid fill."
    },
    {
      "name": "size",
      "type": "\"small\" | \"medium\" | \"large\"",
      "default": "medium",
      "required": false,
      "description": "Height 16 / 20 / 24px. Match the parent: small in tabs, medium in nav items."
    },
    {
      "name": "isHiddenWhenZero",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "Renders nothing when value is 0. Not in Blade; default false is proposed: UNDEFINED · needs decision."
    },
    {
      "name": "accessibilityLabel",
      "type": "string",
      "default": null,
      "required": false,
      "description": "Spoken text when the parent label can't carry the count, such as \"12 unread\". Usually leave empty and name the parent instead."
    },
    {
      "name": "testID",
      "type": "string",
      "default": null,
      "required": false,
      "description": "Test hook, rendered as data-testid."
    }
  ],
  "undefined": [
    "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"
  ],
  "sizes": {
    "heightMinWidth": "small --size-16 · medium --size-20 · large --size-24",
    "paddingInline": "small --spacing-2 · medium --spacing-15 · large --spacing-3",
    "radius": "--border-radius-none (UNDEFINED: Blade uses a pill)",
    "valueFontSize": "small and medium --typography-fonts-size-75 · large --typography-fonts-size-100",
    "valueLineHeight": "small and medium --typography-line-heights-50 · large --typography-line-heights-100",
    "valueFontWeight": "--typography-fonts-weight-medium",
    "valueFontFamily": "--typography-fonts-family-text",
    "placement": "inline after the parent label, gap --spacing-2, vertically centred; width grows with the value from min-width = height",
    "decoration": "no border, no icon, no shadow"
  },
  "states": [
    {
      "name": "neutral · subtle",
      "trigger": "color=\"neutral\" emphasis=\"subtle\"",
      "tokens": {
        "bg": "feedback.background.neutral.subtle",
        "text": "feedback.text.neutral.intense",
        "contrast": "15.68 / 14.27"
      }
    },
    {
      "name": "neutral · intense",
      "trigger": "color=\"neutral\" emphasis=\"intense\"",
      "tokens": {
        "bg": "feedback.background.neutral.intense",
        "text": "surface.text.staticWhite.normal (Dark: static black)",
        "contrast": "17.72 / 15.68"
      }
    },
    {
      "name": "primary · subtle",
      "trigger": "color=\"primary\" emphasis=\"subtle\"",
      "tokens": {
        "bg": "surface.background.primary.subtle",
        "text": "surface.text.onPrimary.normal",
        "contrast": "18.03 / 8.62"
      }
    },
    {
      "name": "primary · intense",
      "trigger": "color=\"primary\" emphasis=\"intense\"",
      "tokens": {
        "bg": "surface.background.primary.intense",
        "text": "surface.text.onPrimary.normal",
        "contrast": "14.00 / 14.00"
      }
    },
    {
      "name": "positive · subtle",
      "trigger": "color=\"positive\" emphasis=\"subtle\"",
      "tokens": {
        "bg": "feedback.background.positive.subtle",
        "text": "feedback.text.positive.intense",
        "contrast": "4.72 / 10.67"
      }
    },
    {
      "name": "positive · intense",
      "trigger": "color=\"positive\" emphasis=\"intense\"",
      "tokens": {
        "bg": "feedback.background.positive.intense",
        "text": "surface.text.staticWhite.normal",
        "contrast": "4.95 / 3.22 (fails in Dark): UNDEFINED · needs decision"
      }
    },
    {
      "name": "negative · subtle",
      "trigger": "color=\"negative\" emphasis=\"subtle\"",
      "tokens": {
        "bg": "feedback.background.negative.subtle",
        "text": "feedback.text.negative.intense",
        "contrast": "5.87 / 8.42"
      }
    },
    {
      "name": "negative · intense",
      "trigger": "color=\"negative\" emphasis=\"intense\"",
      "tokens": {
        "bg": "feedback.background.negative.intense",
        "text": "surface.text.staticWhite.normal",
        "contrast": "6.42 / 4.77"
      }
    },
    {
      "name": "notice · subtle",
      "trigger": "color=\"notice\" emphasis=\"subtle\"",
      "tokens": {
        "bg": "feedback.background.notice.subtle",
        "text": "feedback.text.notice.intense",
        "contrast": "6.84 / 10.37"
      }
    },
    {
      "name": "notice · intense",
      "trigger": "color=\"notice\" emphasis=\"intense\"",
      "tokens": {
        "bg": "feedback.background.notice.intense",
        "text": "surface.text.staticBlack.normal",
        "contrast": "11.55 / 11.55"
      }
    },
    {
      "name": "information · subtle",
      "trigger": "color=\"information\" emphasis=\"subtle\"",
      "tokens": {
        "bg": "feedback.background.information.subtle",
        "text": "feedback.text.information.intense",
        "contrast": "6.28 / 8.15"
      }
    },
    {
      "name": "information · intense",
      "trigger": "color=\"information\" emphasis=\"intense\"",
      "tokens": {
        "bg": "feedback.background.information.intense",
        "text": "surface.text.staticWhite.normal",
        "contrast": "6.83 / 5.25"
      }
    }
  ],
  "behaviour": {
    "overflow": "When max is set and value > max, render \"{max}+\" (e.g. max=99 -> \"99+\"); without max, render the value.",
    "numberFormat": "Integers only, grouped with the locale separator (\"1,284\"). No units, words or leading \"+\".",
    "zero": "isHiddenWhenZero: proposed default false (render \"0\"); hide in nav, show in filter tabs. Not in Blade. UNDEFINED · needs decision.",
    "width": "min-width equals height; width grows with the value; never fixed width.",
    "liveUpdates": "No animation of the number. aria-live=\"polite\" goes on the parent region only when the change matters.",
    "colour": "neutral for totals; negative or notice only when the count needs attention.",
    "placement": "Inline after the parent's label, gap --spacing-2, vertically centred; never floats over an icon.",
    "truncation": "Never truncate or ellipsize the value; cap with max instead."
  },
  "keyboard": [
    {
      "key": "Tab / Shift+Tab",
      "action": "Skips the counter; focus lands on the parent tab or nav item."
    },
    {
      "key": "Arrow keys",
      "action": "Handled by the parent (Tabs, nav); unchanged by the counter."
    },
    {
      "key": "Enter / Space",
      "action": "Activates the parent; the counter has no action."
    },
    {
      "key": "Click",
      "action": "Hits the parent; the counter adds no handler and no extra target."
    }
  ],
  "accessibility": {
    "summary": "Markup: <span>12</span> inside the parent. No role, no tabindex. The parent carries the accessible name (\"Inbox, 12 unread\"; \"99+\" reads \"more than 99\").",
    "aria": [
      {
        "element": "span (counter)",
        "attributes": "role",
        "when": "none"
      },
      {
        "element": "span (counter)",
        "attributes": "tabindex",
        "when": "none (never focusable)"
      },
      {
        "element": "span (counter)",
        "attributes": "aria-hidden=\"true\"",
        "when": "set by the app when the parent name already includes the count"
      },
      {
        "element": "span (counter)",
        "attributes": "aria-label",
        "when": "accessibilityLabel, only when the count is not in the parent name"
      },
      {
        "element": "parent",
        "attributes": "accessible name",
        "when": "\"Inbox, 12 unread\""
      },
      {
        "element": "parent region",
        "attributes": "aria-live=\"polite\"",
        "when": "only when the update matters; never on every tab counter"
      },
      {
        "element": "visually hidden text",
        "attributes": "text",
        "when": "\"12 unread\" when the parent label can't include the count"
      }
    ]
  },
  "usage": {
    "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."
    ],
    "dont": [
      "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."
    ]
  },
  "example": "<Counter value={128} max={99} size=\"small\" />"
}
