{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "button-underline-grow",
  "type": "registry:component",
  "title": "Button Underline Grow",
  "description": "A text link or button whose underline grows from the center while an arrow nudges forward. After it is used, the text shifts to a visited color.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "buttons",
    "link",
    "underline",
    "arrow",
    "text",
    "visited",
    "hover"
  ],
  "docs": "https://hyperblur.dev/effects/button-underline-grow",
  "files": [
    {
      "path": "registry/hyperblur/button-underline-grow.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/button-underline-grow.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface ButtonUnderlineGrowProps\n  extends Omit<React.HTMLAttributes<HTMLElement>, \"color\"> {\n  href?: string;\n  target?: string;\n  rel?: string;\n  type?: \"button\" | \"submit\" | \"reset\";\n  variant?: \"accent\" | \"plain\";\n  accent?: string;\n  visitedColor?: string;\n  size?: \"sm\" | \"md\" | \"lg\";\n  arrow?: boolean | React.ReactNode;\n  idle?: boolean;\n  loading?: boolean;\n  disabled?: boolean;\n}\n\nconst arrowIcon = (\n  <svg viewBox=\"0 0 24 24\" width=\"100%\" height=\"100%\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n    <path d=\"M5 12h14\" />\n    <path d=\"M13 6l6 6-6 6\" />\n  </svg>\n);\n\nconst css = `\n.hb-ya7 {\n  --hb-ya7-fs: 0.9375rem;\n  position: relative;\n  display: inline-flex;\n  align-items: center;\n  gap: 0.45em;\n  box-sizing: border-box;\n  margin: 0;\n  padding: 0.3em 0;\n  font: inherit;\n  font-size: var(--hb-ya7-fs);\n  font-weight: 500;\n  line-height: 1.25;\n  color: var(--hb-ya7-fg);\n  text-decoration: none;\n  white-space: nowrap;\n  background: none;\n  border: 0;\n  cursor: pointer;\n  -webkit-tap-highlight-color: transparent;\n  transition: color 0.3s ease;\n}\n.hb-ya7 *, .hb-ya7 *::before, .hb-ya7 *::after { box-sizing: border-box; }\n.hb-ya7[data-size=\"sm\"] { --hb-ya7-fs: 0.8125rem; }\n.hb-ya7[data-size=\"lg\"] { --hb-ya7-fs: 1.125rem; }\n.hb-ya7[data-variant=\"accent\"] { --hb-ya7-fg: color-mix(in srgb, var(--hb-ya7-c) 72%, #fff); }\n.hb-ya7[data-variant=\"plain\"] { --hb-ya7-fg: #ededed; }\n.hb-ya7[data-visited=\"true\"] { color: var(--hb-ya7-v); }\na.hb-ya7:visited { color: var(--hb-ya7-v); }\n.hb-ya7:focus-visible { outline: 2px solid var(--hb-ya7-c); outline-offset: 4px; border-radius: 4px; }\n.hb-ya7[aria-disabled=\"true\"], .hb-ya7:disabled { opacity: 0.45; cursor: not-allowed; }\n.hb-ya7[aria-busy=\"true\"] { cursor: progress; }\n.hb-ya7-text { position: relative; display: inline-block; }\n.hb-ya7-text::before {\n  content: \"\";\n  position: absolute;\n  left: 0;\n  right: 0;\n  bottom: -0.18em;\n  height: 1px;\n  background: currentColor;\n  opacity: 0.2;\n}\n.hb-ya7-text::after {\n  content: \"\";\n  position: absolute;\n  left: 0;\n  right: 0;\n  bottom: -0.2em;\n  height: 2px;\n  border-radius: 2px;\n  background: var(--hb-ya7-line, var(--hb-ya7-c));\n  transform: scaleX(0);\n  transform-origin: 50% 50%;\n  transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);\n}\n.hb-ya7[data-visited=\"true\"] .hb-ya7-text::after { background: var(--hb-ya7-v); }\n.hb-ya7-arrow {\n  display: grid;\n  flex: none;\n  place-items: center;\n  width: 1.05em;\n  height: 1.05em;\n  transition: transform 0.4s cubic-bezier(0.3, 1.5, 0.5, 1);\n}\n.hb-ya7-arrow > svg { display: block; width: 100%; height: 100%; }\n.hb-ya7:not([aria-disabled=\"true\"]):not(:disabled):hover .hb-ya7-text::after,\n.hb-ya7:not([aria-disabled=\"true\"]):not(:disabled):focus-visible .hb-ya7-text::after { transform: scaleX(1); }\n.hb-ya7:not([aria-disabled=\"true\"]):not(:disabled):hover .hb-ya7-arrow,\n.hb-ya7:not([aria-disabled=\"true\"]):not(:disabled):focus-visible .hb-ya7-arrow { transform: translateX(0.32em); }\n.hb-ya7:not([aria-disabled=\"true\"]):not(:disabled):active .hb-ya7-arrow { transform: translateX(0.55em); }\n.hb-ya7[data-idle=\"true\"] .hb-ya7-text::after { animation: hb-ya7-breathe 3.6s cubic-bezier(0.4, 0, 0.2, 1) infinite; }\n.hb-ya7[data-idle=\"true\"] .hb-ya7-arrow { animation: hb-ya7-nudge 3.6s cubic-bezier(0.4, 0, 0.2, 1) infinite; }\n.hb-ya7[data-idle=\"true\"]:hover .hb-ya7-text::after,\n.hb-ya7[data-idle=\"true\"]:focus-visible .hb-ya7-text::after,\n.hb-ya7[data-idle=\"true\"]:hover .hb-ya7-arrow,\n.hb-ya7[data-idle=\"true\"]:focus-visible .hb-ya7-arrow { animation: none; }\n.hb-ya7-spin {\n  width: 0.95em;\n  height: 0.95em;\n  border: 2px solid currentColor;\n  border-right-color: transparent;\n  border-radius: 50%;\n  animation: hb-ya7-turn 0.7s linear infinite;\n}\n@keyframes hb-ya7-breathe {\n  0%, 100% { transform: scaleX(0); }\n  40%, 60% { transform: scaleX(1); }\n}\n@keyframes hb-ya7-nudge {\n  0%, 100% { transform: translateX(0); }\n  40%, 60% { transform: translateX(0.32em); }\n}\n@keyframes hb-ya7-turn {\n  to { transform: rotate(360deg); }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-ya7, .hb-ya7-text::after, .hb-ya7-arrow { transition: none; }\n  .hb-ya7[data-idle=\"true\"] .hb-ya7-text::after, .hb-ya7[data-idle=\"true\"] .hb-ya7-arrow { animation: none; }\n  .hb-ya7-spin { animation-duration: 2s; }\n}\n`;\n\nexport function ButtonUnderlineGrow({\n  href,\n  target,\n  rel,\n  type = \"button\",\n  variant = \"accent\",\n  accent = \"#2f7bff\",\n  visitedColor = \"#b69cff\",\n  size = \"md\",\n  arrow = true,\n  idle = false,\n  loading = false,\n  disabled = false,\n  className = \"\",\n  style,\n  children,\n  onClick,\n  ...rest\n}: ButtonUnderlineGrowProps) {\n  const [visited, setVisited] = React.useState(false);\n  const blocked = disabled || loading;\n  const vars = {\n    \"--hb-ya7-c\": accent,\n    \"--hb-ya7-v\": visitedColor,\n    ...style,\n  } as React.CSSProperties;\n\n  const arrowNode = arrow === true ? arrowIcon : arrow === false ? null : arrow;\n  const content = (\n    <>\n      <span className=\"hb-ya7-text\">{children}</span>\n      {loading ? (\n        <span className=\"hb-ya7-arrow\" aria-hidden=\"true\">\n          <span className=\"hb-ya7-spin\" />\n        </span>\n      ) : arrowNode ? (\n        <span className=\"hb-ya7-arrow\" aria-hidden=\"true\">{arrowNode}</span>\n      ) : null}\n    </>\n  );\n\n  const common = {\n    className: `hb-ya7 ${className}`,\n    style: vars,\n    \"data-variant\": variant,\n    \"data-size\": size,\n    \"data-visited\": visited,\n    \"data-idle\": idle,\n    \"aria-busy\": loading || undefined,\n    onClick: (e: React.MouseEvent<HTMLElement>) => {\n      if (blocked) {\n        e.preventDefault();\n        return;\n      }\n      setVisited(true);\n      onClick?.(e);\n    },\n    ...rest,\n  };\n\n  return (\n    <>\n      <style href=\"hb-button-underline-grow\" precedence=\"default\">{css}</style>\n      {href ? (\n        <a\n          href={blocked ? undefined : href}\n          target={target}\n          rel={target === \"_blank\" ? (rel ?? \"noopener noreferrer\") : rel}\n          aria-disabled={blocked || undefined}\n          {...common}\n        >\n          {content}\n        </a>\n      ) : (\n        <button type={type} disabled={disabled} {...common}>\n          {content}\n        </button>\n      )}\n    </>\n  );\n}\n"
    }
  ]
}