{
  "$schema": "https://nook-ui.dev/schema/registry-item.json",
  "name": "button",
  "type": "registry:ui",
  "title": "Button",
  "description": "Triggers an action. Comes with variants, sizes and a loading state, and exports its styles for links.",
  "dependencies": [
    "class-variance-authority@^0.7.1"
  ],
  "registryDependencies": [
    "icons",
    "utils"
  ],
  "files": [
    {
      "path": "ui/button.tsx",
      "type": "registry:ui",
      "content": "import * as React from \"react\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport { LoaderIcon } from \"~nook/icons\";\nimport { cn } from \"~nook/lib/utils\";\n\nexport const buttonVariants = cva(\n  \"inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-md border-(length:--edge) border-transparent text-sm font-medium select-none transition-[color,background-color,border-color,box-shadow,transform,opacity] duration-(--motion-fast) ease-(--motion-ease) motion-reduce:transition-none outline-0 hover:[transform:var(--lift)] active:[transform:var(--press)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 aria-busy:pointer-events-none aria-invalid:outline-destructive motion-reduce:transform-none [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0\",\n  {\n    variants: {\n      variant: {\n        default: \"border-(--fill-edge) bg-primary [background-image:var(--btn-shine)] text-primary-foreground shadow-(--btn-shadow) hover:bg-primary/90 active:shadow-(--btn-shadow-press)\",\n        secondary: \"border-(--fill-edge) bg-secondary text-secondary-foreground shadow-(--btn-shadow-quiet) hover:bg-secondary/80 active:shadow-(--btn-shadow-press)\",\n        outline: \"border-(--field-edge) bg-background shadow-(--btn-shadow-quiet) hover:bg-accent hover:text-accent-foreground active:shadow-(--btn-shadow-press)\",\n        ghost: \"hover:bg-accent hover:text-accent-foreground\",\n        destructive: \"border-(--fill-edge) bg-destructive [background-image:var(--btn-shine)] text-destructive-foreground shadow-(--btn-shadow) hover:bg-destructive/90 active:shadow-(--btn-shadow-press)\",\n        link: \"text-foreground underline decoration-brand decoration-2 underline-offset-4 hover:bg-accent\",\n      },\n      size: {\n        sm: \"h-control-sm px-inset-sm text-xs\",\n        md: \"h-control px-inset\",\n        lg: \"h-control-lg px-inset-lg text-base\",\n        icon: \"size-control\",\n      },\n    },\n    defaultVariants: { variant: \"default\", size: \"md\" },\n  },\n);\n\nexport interface ButtonProps\n  extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n    VariantProps<typeof buttonVariants> {\n  /** Shows the loader and ignores presses, while keeping focus on the button. */\n  loading?: boolean;\n}\n\n/**\n * A button. To style a link like a button, pass `buttonVariants()` to its className.\n */\nexport const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(function Button(\n  { className, variant, size, type = \"button\", loading = false, onClick, children, ...props },\n  ref,\n) {\n  // Children are only set when there are some. A Button used as `render={<Button />}`\n  // must stay childless so the wrapping component can supply its own.\n  const content = loading ? (\n    <>\n      <LoaderIcon />\n      {size === \"icon\" ? null : children}\n    </>\n  ) : (\n    children\n  );\n  return (\n    <button\n      ref={ref}\n      // While loading the button is not `disabled`, which would drop keyboard focus.\n      // It stops acting instead: no click handler, and no form submit.\n      type={loading ? \"button\" : type}\n      aria-busy={loading || undefined}\n      aria-disabled={loading || undefined}\n      className={cn(buttonVariants({ variant, size }), className)}\n      onClick={loading ? undefined : onClick}\n      {...props}\n      {...(content === undefined ? null : { children: content })}\n    />\n  );\n});\n"
    }
  ],
  "meta": {
    "docs": {
      "accessibility": "Renders a native button with type=button by default. While `loading`, the button sets `aria-busy`, ignores presses and keeps keyboard focus. To make a link look like a button, put `buttonVariants()` on the anchor.",
      "parts": [
        {
          "name": "Button",
          "description": "The button element.",
          "props": [
            {
              "name": "loading",
              "type": "boolean",
              "default": "false",
              "description": "Shows the loader and ignores presses."
            },
            {
              "name": "...props",
              "type": "React.ButtonHTMLAttributes<HTMLButtonElement>",
              "description": "Everything the native element accepts, such as `id`, `aria-*` and event handlers."
            }
          ]
        }
      ],
      "variants": [
        {
          "name": "variant",
          "values": [
            "default",
            "secondary",
            "outline",
            "ghost",
            "destructive",
            "link"
          ],
          "default": "default"
        },
        {
          "name": "size",
          "values": [
            "sm",
            "md",
            "lg",
            "icon"
          ],
          "default": "md"
        }
      ],
      "example": "import { buttonVariants } from \"@/components/ui/button\";\n\nexport default function ButtonAsLink() {\n  return (\n    <a href=\"#as-link\" className={buttonVariants({ variant: \"outline\" })}>\n      I am a link\n    </a>\n  );\n}"
    }
  }
}
