{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "button",
  "type": "registry:ui",
  "title": "Button",
  "description": "Primary, secondary, ghost, and danger buttons in three sizes with icon support.",
  "dependencies": [],
  "registryDependencies": [
    "cx",
    "directional-icon",
    "globals"
  ],
  "files": [
    {
      "path": "components/base/buttons/button.tsx",
      "content": "import type {\n  AnchorHTMLAttributes,\n  ButtonHTMLAttributes,\n  ComponentType,\n  ReactNode,\n  Ref,\n} from \"react\";\nimport { cx, sortCx } from \"@/utils/cx\";\nimport { directionalIconClass } from \"@/utils/directional-icon\";\n\n/**\n * Figma source: Board UI → Buttons (node 3656:13819).\n *\n * Variant matrix from Figma:\n *   Type     = Primary | Secondary | Ghost | Danger\n *   Size     = Medium  | Small | Xs\n *   State    = Default | Hover | Active | Disabled        (CSS pseudo)\n *   OnlyIcon = false   | true\n *\n * Sizing (1:1 with Figma):\n *\n *                       Medium                    Small                     Xs\n *   container          h=36, p=8,   r=10         h=32, px=8 py=6, r=8      h=24, px=8, r=4\n *   gap                 2px                       2px                      1.33px→1\n *   icon                20×20                     18×18                    14×14\n *   label wrapper       px=4                      px=2                     px=2\n *   text style          Body 1/Medium             Body 1/Medium            Caption 1/Semibold\n *   icon-only square    36×36 (content-derived)   32×32 (forced size)      24×24 (forced size)\n *\n * `xs` is the smallest tier — first needed for the calendar template's\n * event-details modal (\"Join\" / edit-icon buttons, node 3920:10954), which\n * scales every dimension down by the same ~0.667 factor from Figma; the\n * table above rounds those to clean pixel values rather than reproducing\n * the fractional source numbers.\n *\n * Icons are rendered by the component itself via the `leadingIcon` /\n * `trailingIcon` props so the consumer can't pass the wrong size. Pass\n * a Remix Icon component reference (`RiAddLine`, not `<RiAddLine />`).\n *\n * For icon-only buttons:\n *   <Button iconOnly leadingIcon={RiAddLine} aria-label=\"Add\" />\n *\n * The HTML `type` prop is preserved; Figma's \"Type\" enum is renamed to\n * `variant` to avoid the clash.\n */\n\ntype ButtonVariant = \"primary\" | \"secondary\" | \"ghost\" | \"danger\";\ntype ButtonSize = \"medium\" | \"small\" | \"xs\";\n\ntype IconComponent = ComponentType<{\n  className?: string;\n  \"aria-hidden\"?: boolean | \"true\" | \"false\";\n}>;\n\nexport interface ButtonProps\n  extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, \"children\"> {\n  variant?: ButtonVariant;\n  size?: ButtonSize;\n  iconOnly?: boolean;\n  leadingIcon?: IconComponent;\n  trailingIcon?: IconComponent;\n  children?: ReactNode;\n  ref?: Ref<HTMLButtonElement>;\n}\n\nexport interface ButtonLinkProps\n  extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, \"children\"> {\n  variant?: ButtonVariant;\n  size?: ButtonSize;\n  iconOnly?: boolean;\n  leadingIcon?: IconComponent;\n  trailingIcon?: IconComponent;\n  children?: ReactNode;\n  ref?: Ref<HTMLAnchorElement>;\n}\n\nconst styles = sortCx({\n  base: [\n    \"inline-flex items-center justify-center gap-0.5 whitespace-nowrap overflow-hidden\",\n    \"font-sans select-none cursor-pointer\",\n    \"button-press-motion\",\n    \"outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-border-focus-ring\",\n    \"disabled:cursor-not-allowed aria-disabled:cursor-not-allowed\",\n  ].join(\" \"),\n\n  // Base shape per size (used when label is present OR medium icon-only).\n  size: {\n    medium: \"h-9 rounded-2lg p-2 text-body-medium\",\n    small:  \"h-8 rounded-lg px-2 py-1.5 text-body-medium\",\n    xs:     \"h-6 rounded-sm px-2 text-caption-1-semibold\",\n  },\n\n  // Icon-only override:\n  //   Medium → keep p-2; w expands from content (8+20+8 = 36) → square.\n  //   Small  → Figma forces 32×32 even though 8+18+8=34, so we hard-set size-8\n  //            and zero the padding; the inner flex centers the 18px icon.\n  //   Xs     → forces 24×24, content-centered — used for the calendar\n  //            template's edit-icon buttons (timezone/participants/reminder).\n  iconOnlySize: {\n    medium: \"\",                // base size already produces 36×36 with a 20px icon\n    small:  \"size-8 p-0\",      // hard 32×32, content-centered\n    xs:     \"size-6 p-0\",      // hard 24×24, content-centered\n  },\n\n  icon: {\n    medium: \"size-5 shrink-0\",        // 20px\n    small:  \"size-[18px] shrink-0\",   // 18px\n    xs:     \"size-3.5 shrink-0\",      // 14px\n  },\n\n  label: {\n    medium: \"inline-flex items-center justify-center px-1 shrink-0\",    // px=4\n    small:  \"inline-flex items-center justify-center px-0.5 shrink-0\",  // px=2\n    xs:     \"inline-flex items-center justify-center px-0.5 shrink-0\",  // px=2\n  },\n\n  variant: {\n    primary: [\n      \"bg-button-primary text-text-white shadow-xs\",\n      \"disabled:text-button-primary-disabled-foreground disabled:shadow-none\",\n      \"aria-disabled:text-button-primary-disabled-foreground aria-disabled:shadow-none\",\n    ].join(\" \"),\n    danger: [\n      \"bg-button-danger text-text-white shadow-xs\",\n      \"disabled:text-foreground-disabled-danger disabled:shadow-none\",\n      \"aria-disabled:text-foreground-disabled-danger aria-disabled:shadow-none\",\n    ].join(\" \"),\n    secondary: [\n      \"bg-background-primary-default text-text-primary\",\n      \"border border-border-button-default shadow-xs\",\n      \"hover:bg-background-primary-hover  hover:border-border-button-hover\",\n      \"active:bg-background-primary-active active:border-border-button-active\",\n      \"disabled:bg-background-primary-disabled disabled:border-border-button-default disabled:text-text-tertiary disabled:shadow-none\",\n      \"aria-disabled:bg-background-primary-disabled aria-disabled:border-border-button-default aria-disabled:text-text-tertiary aria-disabled:shadow-none\",\n    ].join(\" \"),\n    ghost: [\n      \"bg-button-ghost-background text-button-ghost-foreground\",\n      \"hover:bg-button-ghost-hover active:bg-button-ghost-active\",\n      \"disabled:bg-button-ghost-disabled disabled:text-button-ghost-disabled-foreground disabled:shadow-none\",\n      \"aria-disabled:bg-button-ghost-disabled aria-disabled:text-button-ghost-disabled-foreground aria-disabled:shadow-none\",\n    ].join(\" \"),\n  },\n});\n\nexport function Button({\n  variant = \"primary\",\n  size = \"medium\",\n  iconOnly = false,\n  leadingIcon: Leading,\n  trailingIcon: Trailing,\n  children,\n  className,\n  type = \"button\",\n  ref,\n  ...props\n}: ButtonProps) {\n  return (\n    <button\n      ref={ref}\n      type={type}\n      className={cx(\n        styles.base,\n        styles.size[size],\n        styles.variant[variant],\n        iconOnly && styles.iconOnlySize[size],\n        className,\n      )}\n      {...props}\n    >\n      {Leading ? <Leading className={cx(styles.icon[size], directionalIconClass(Leading))} aria-hidden /> : null}\n      {!iconOnly && children !== undefined && children !== null && (\n        <span className={styles.label[size]}>{children}</span>\n      )}\n      {!iconOnly && Trailing ? (\n        <Trailing className={cx(styles.icon[size], directionalIconClass(Trailing))} aria-hidden />\n      ) : null}\n    </button>\n  );\n}\n\n/** Anchor counterpart to Button for navigational actions. */\nexport function ButtonLink({\n  variant = \"primary\",\n  size = \"medium\",\n  iconOnly = false,\n  leadingIcon: Leading,\n  trailingIcon: Trailing,\n  children,\n  className,\n  ref,\n  ...props\n}: ButtonLinkProps) {\n  return (\n    <a\n      ref={ref}\n      className={cx(\n        styles.base,\n        styles.size[size],\n        styles.variant[variant],\n        iconOnly && styles.iconOnlySize[size],\n        className,\n      )}\n      {...props}\n    >\n      {Leading ? <Leading className={cx(styles.icon[size], directionalIconClass(Leading))} aria-hidden /> : null}\n      {!iconOnly && children !== undefined && children !== null && (\n        <span className={styles.label[size]}>{children}</span>\n      )}\n      {!iconOnly && Trailing ? (\n        <Trailing className={cx(styles.icon[size], directionalIconClass(Trailing))} aria-hidden />\n      ) : null}\n    </a>\n  );\n}\n\n/** Style maps, exported for advanced composition and the dev Design Tuner. */\nexport const buttonStyles = styles;\n",
      "type": "registry:component",
      "target": "components/base/buttons/button.tsx"
    }
  ],
  "meta": {
    "docsUrl": "https://www.boardui.com/components/button",
    "example": "import { RiArrowRightLine } from \"@remixicon/react\";\nimport { Button } from \"@/components/base/buttons/button\";\n\nexport function Example() {\n  return (\n    <div className=\"flex items-center gap-3\">\n      <Button>Get started</Button>\n      <Button variant=\"secondary\" trailingIcon={RiArrowRightLine}>\n        Continue\n      </Button>\n      <Button variant=\"ghost\">Mark as done</Button>\n      <Button variant=\"danger\">Delete</Button>\n    </div>\n  );\n}",
    "snippets": [
      {
        "label": "variants",
        "code": "<Button variant=\"primary\">Primary</Button>     {/* blue gradient (default) */}\n<Button variant=\"secondary\">Secondary</Button> {/* white surface + hairline border */}\n<Button variant=\"ghost\">Ghost</Button>         {/* blue-100 semantic surface */}\n<Button variant=\"danger\">Danger</Button>       {/* red gradient */}"
      },
      {
        "label": "sizes",
        "code": "<Button size=\"medium\">Medium</Button> {/* 36px (default) */}\n<Button size=\"small\">Small</Button>   {/* 32px */}\n<Button size=\"xs\">Xs</Button>         {/* 24px */}"
      },
      {
        "label": "icons",
        "code": "import { RiAddLine, RiArrowRightLine } from \"@remixicon/react\";\n\n{/* Pass component references, not rendered elements */}\n<Button leadingIcon={RiAddLine}>New project</Button>\n<Button trailingIcon={RiArrowRightLine}>Continue</Button>\n\n{/* Icon-only requires an aria-label */}\n<Button iconOnly leadingIcon={RiAddLine} aria-label=\"Add\" />"
      }
    ]
  }
}
