{
  "component": "Button",
  "package": "@blade-ai/weft",
  "import": "import { Button } from \"@blade-ai/weft\";",
  "iconsImport": "import { ArrowRightIcon, MoreIcon } from \"@blade-ai/weft/icons\";",
  "status": "stable",
  "version": "0.4.0",
  "updated": "2026-11-18",
  "docs": "/components/button",
  "description": "Starts an action or moves a flow forward. Five variants, four sizes, and four colours; square, flat and token-driven.",
  "props": [
    { "name": "children", "type": "string", "default": null, "required": true, "description": "Verb-first label; omit when iconOnly (required unless iconOnly)." },
    { "name": "variant", "type": "\"primary\" | \"secondary\" | \"tertiary\" | \"ghost\" | \"link\"", "values": ["primary", "secondary", "tertiary", "ghost", "link"], "default": "primary", "required": false, "description": "One primary per view." },
    { "name": "color", "type": "\"primary\" | \"white\" | \"positive\" | \"negative\"", "values": ["primary", "white", "positive", "negative"], "default": "primary", "required": false, "description": "positive / negative: primary + secondary only; white: primary, secondary, tertiary; ghost + link: primary only. Unsupported combinations fall back to color=\"primary\"." },
    { "name": "size", "type": "\"xsmall\" | \"small\" | \"medium\" | \"large\"", "values": ["xsmall", "small", "medium", "large"], "default": "medium", "required": false, "description": "Height 28 / 32 / 40 / 48px." },
    { "name": "icon", "type": "IconComponent", "default": null, "required": false, "description": "Icon 12 / 14 / 16 / 16px, colour = label token. Import from @blade-ai/weft/icons." },
    { "name": "iconPosition", "type": "\"left\" | \"right\"", "values": ["left", "right"], "default": "left", "required": false, "description": "Side of the label the icon sits on. Both sides at once: UNDEFINED." },
    { "name": "iconOnly", "type": "boolean", "default": false, "required": false, "description": "Square button (width = height). Requires accessibilityLabel." },
    { "name": "accessibilityLabel", "type": "string", "default": null, "required": false, "requiredWhen": "iconOnly", "description": "Rendered as aria-label; required when iconOnly." },
    { "name": "isDisabled", "type": "boolean", "default": false, "required": false, "description": "Native disabled, opacity 50%. Skipped by Tab." },
    { "name": "isLoading", "type": "boolean", "default": false, "required": false, "description": "Spinner, label hidden, width locked, aria-busy. Stays focusable; clicks ignored." },
    { "name": "isFullWidth", "type": "boolean", "default": false, "required": false, "description": "Stretches to the parent's width." },
    { "name": "type", "type": "\"button\" | \"submit\" | \"reset\"", "values": ["button", "submit", "reset"], "default": "button", "required": false, "description": "Ignored when href is set." },
    { "name": "href", "type": "string", "default": null, "required": false, "description": "Renders <a href> instead of <button>." },
    { "name": "onClick", "type": "(event: MouseEvent) => void", "default": null, "required": false, "description": "Not fired while isDisabled or isLoading." }
  ],
  "variants": {
    "primary": { "colors": ["primary", "white", "positive", "negative"] },
    "secondary": { "colors": ["primary", "white", "positive", "negative"] },
    "tertiary": { "colors": ["primary", "white"] },
    "ghost": { "colors": ["primary"] },
    "link": { "colors": ["primary"] }
  },
  "sizes": {
    "xsmall": { "height": "size.28", "paddingX": "spacing.16", "gap": "spacing.15", "icon": "size.12", "fontSize": "typography.fonts.size.75", "lineHeight": "typography.lineHeights.50" },
    "small": { "height": "size.32", "paddingX": "spacing.17", "gap": "spacing.3", "icon": "size.14", "fontSize": "typography.fonts.size.1200", "lineHeight": "typography.lineHeights.100" },
    "medium": { "height": "size.40", "paddingX": "spacing.6", "gap": "spacing.3", "icon": "size.16", "fontSize": "typography.fonts.size.1200", "lineHeight": "typography.lineHeights.100" },
    "large": { "height": "size.48", "paddingX": "spacing.7", "gap": "spacing.3", "icon": "size.16", "fontSize": "typography.fonts.size.100", "lineHeight": "typography.lineHeights.100" },
    "radius": "border.radius.none (themeable via --weft-radius)",
    "focusRing": "border.width.3 + interactive.border.primary.faded",
    "minWidth": "UNDEFINED",
    "maxWidth": "UNDEFINED (long labels: truncate or wrap undecided)"
  },
  "states": [
    { "name": "default", "trigger": "rest", "tokens": { "primary": { "bg": "interactive.background.primary.default", "text": "interactive.text.onPrimary.normal" }, "secondary": { "bg": "surface.background.gray.subtle", "border": "interactive.border.gray.default", "text": "interactive.text.gray.normal" }, "tertiary": { "bg": "interactive.background.gray.default", "text": "interactive.text.gray.normal" }, "ghost": { "bg": "transparent", "text": "interactive.text.gray.normal" }, "link": { "text": "interactive.text.primary.normal" } } },
    { "name": "hover", "trigger": ":hover", "tokens": { "primary": { "bg": "interactive.background.primary.highlighted" }, "secondary": { "border": "interactive.border.gray.highlighted", "overlay": "interactive.background.gray.faded" }, "tertiary": { "bg": "interactive.background.gray.highlighted" }, "ghost": { "bg": "interactive.background.gray.faded" }, "link": { "textDecoration": "underline 1px" } } },
    { "name": "focus", "trigger": ":focus-visible", "tokens": { "ring": "inset border.width.thin interactive.border.primary.default + 0 0 0 border.width.3 interactive.border.primary.faded", "white": { "ring": "border.width.3 interactive.border.static.white.default" } } },
    { "name": "pressed", "trigger": ":active", "tokens": { "primary": { "bg": "UNDEFINED (interactive.background.primary.pressed) → falls back to interactive.background.primary.highlighted" }, "secondary": { "overlay": "interactive.background.gray.faded.highlighted" }, "tertiary": { "bg": "UNDEFINED (interactive.background.gray.pressed) → falls back to interactive.background.gray.highlighted" }, "ghost": { "bg": "interactive.background.gray.faded.highlighted" }, "link": { "text": "feedback.text.positive.intense" } } },
    { "name": "disabled", "trigger": "isDisabled", "tokens": { "opacity": "opacity.600", "cursor": "not-allowed" } },
    { "name": "loading", "trigger": "isLoading", "tokens": { "opacity": "opacity.600", "label": "opacity.0", "spinner": "label colour token" } },
    { "name": "positive", "trigger": "color=\"positive\"", "tokens": { "primary": { "bg": "interactive.background.positive.default", "text": "interactive.text.static.white.normal", "hoverOverlay": "interactive.background.gray.faded.highlighted" }, "secondary": { "bg": "interactive.background.positive.faded", "border": "interactive.border.positive.default", "text": "interactive.text.positive.normal" } } },
    { "name": "negative", "trigger": "color=\"negative\"", "tokens": { "primary": { "bg": "interactive.background.negative.default", "text": "interactive.text.static.white.normal", "hoverOverlay": "interactive.background.gray.faded.highlighted" }, "secondary": { "bg": "interactive.background.negative.faded", "border": "interactive.border.negative.default", "text": "interactive.text.negative.normal" } } },
    { "name": "white", "trigger": "color=\"white\" (on dark surfaces)", "tokens": { "primary": { "bg": "interactive.background.static.white.default", "text": "interactive.text.static.black.normal" }, "secondary": { "border": "interactive.border.static.white.default", "text": "interactive.text.static.white.normal", "hoverBg": "interactive.background.static.white.faded" }, "tertiary": { "bg": "interactive.background.static.white.faded", "text": "interactive.text.static.white.normal", "hoverBg": "interactive.background.static.white.faded.highlighted" } } },
    { "name": "iconOnly", "trigger": "iconOnly", "tokens": { "width": "= height (size.28 / 32 / 40 / 48)", "padding": "spacing.0" } }
  ],
  "behaviour": {
    "click": "onClick fires on activation; not fired while isDisabled or isLoading.",
    "loading": "isLoading shows a spinner, hides the label (opacity 0) so the width stays locked, sets aria-busy=\"true\" and aria-disabled=\"true\"; the button stays focusable.",
    "disabled": "isDisabled sets the native disabled attribute on <button> (skipped by Tab). On <a href> the href is removed, aria-disabled=\"true\" and tabIndex=-1.",
    "linkVsButton": "Set href to navigate (renders <a>); omit href to run an action (renders <button type=\"button\">). Never use a <button> to navigate or an <a> to run an action.",
    "type": "type defaults to \"button\"; it is ignored when href is set.",
    "iconOnly": "iconOnly hides children and makes the button square; accessibilityLabel is required.",
    "colorFallback": "Unsupported variant/color combinations render color=\"primary\"."
  },
  "keyboard": [
    { "key": "Tab / Shift+Tab", "action": "Moves focus to / from the button and shows the ring. Disabled buttons are skipped; loading buttons stay focusable." },
    { "key": "Enter", "action": "Activates <button> and follows <a href>. Ignored while isLoading." },
    { "key": "Space", "action": "Activates <button> on key-up. Does nothing on <a>." },
    { "key": "Escape", "action": "No effect on Button (handled by the parent dialog or menu)." }
  ],
  "accessibility": {
    "summary": "Native <button> / <a> behaviour; no custom key handlers.",
    "aria": [
      { "element": "<button>", "attributes": "native role button · type=\"button\" · name = label", "when": "No href" },
      { "element": "<a href>", "attributes": "native role link · never role=\"button\"", "when": "href set" },
      { "element": "aria-label", "attributes": "= accessibilityLabel", "when": "Required when iconOnly" },
      { "element": "aria-busy · aria-disabled", "attributes": "aria-busy=\"true\" + aria-disabled=\"true\"", "when": "isLoading. Live \"Loading\" announcement: UNDEFINED" },
      { "element": "disabled", "attributes": "native disabled attribute", "when": "isDisabled on <button>" },
      { "element": "icon · spinner <svg>", "attributes": "aria-hidden=\"true\" · focusable=\"false\"", "when": "Always" }
    ]
  },
  "usage": {
    "do": [
      "Use one primary button per view for the main action.",
      "Start labels with a verb (\"Deploy agent\", \"Create workspace\").",
      "Use isLoading for async actions instead of disabling the button.",
      "Use color=\"negative\" only for destructive actions, and confirm them."
    ],
    "dont": [
      "Use a <button> to navigate or an <a> to run an action.",
      "Ship an icon-only button without accessibilityLabel.",
      "Add radius, shadows or raised edges; Weft is square and flat.",
      "Hard-code colours; use the variant tokens."
    ]
  },
  "example": "<Button variant=\"primary\" size=\"medium\" icon={ArrowRightIcon} isLoading={isDeploying} onClick={onDeploy}>Deploy agent</Button>"
}
