{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "link",
  "title": "Link",
  "description": "Inline link with seven underline styles (static, slide-in, grow from center, marker sweep, nudging arrow), line decorations, tones, leading icons and automatic external-link handling. Works with next/link via as.",
  "dependencies": [],
  "registryDependencies": [
    "https://goodui.dev/r/goodui-motion.json",
    "https://goodui.dev/r/locale.json"
  ],
  "files": [
    {
      "path": "registry/components/core/link.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { cn } from \"@/lib/utils\"\nimport { useLabels } from \"@/lib/goodui-locale\"\nimport { GooduiTokens } from \"@/lib/goodui-motion\"\n\n/*\n * One link, independent layers: every axis combines with every other.\n *   underline   none, always, hover (static) · slide, grow-center, highlight, arrow (animated)\n *   decoration  line style for always / hover      tone     color (inherit follows the text around it)\n *   weight, size, iconLeft                          external auto-detected for http(s) links\n * Works with next/link: <Link as={NextLink} href=\"/pricing\">Pricing</Link>.\n */\n\nexport type LinkUnderline = \"none\" | \"always\" | \"hover\" | \"slide\" | \"grow-center\" | \"highlight\" | \"arrow\"\nexport type LinkDecoration = \"solid\" | \"dotted\" | \"dashed\" | \"wavy\"\nexport type LinkTone = \"inherit\" | \"muted\" | \"primary\" | \"neutral\" | \"success\" | \"warning\" | \"danger\" | \"info\"\nexport type LinkWeight = \"inherit\" | \"normal\" | \"medium\" | \"semibold\" | \"bold\"\nexport type LinkSize = \"inherit\" | \"xs\" | \"sm\" | \"base\" | \"lg\"\n\nexport type LinkLabels = {\n  /** Screen-reader note appended to external links. */\n  newTab: string\n}\nconst DEFAULT_LABELS: LinkLabels = { newTab: \"(opens in a new tab)\" }\n\nexport type LinkProps = React.ComponentProps<\"a\"> & {\n  /** none, always, hover (static) or an animated effect: slide, grow-center, highlight (marker fill), arrow. */\n  underline?: LinkUnderline\n  /** Line style for underline=\"always\" and \"hover\". */\n  decoration?: LinkDecoration\n  /** Link color; inherit follows the surrounding text, muted brightens on hover. */\n  tone?: LinkTone\n  /** Font weight; inherit keeps the parent's. */\n  weight?: LinkWeight\n  /** Font size; inherit keeps the parent's. */\n  size?: LinkSize\n  /** Opens in a new tab with an icon. Defaults to true for absolute http(s) URLs. */\n  external?: boolean\n  /** Show the ↗ icon on external links. */\n  externalIcon?: boolean\n  /** Icon before the text, sized to 1em. */\n  iconLeft?: React.ReactNode\n  /** Render another element, e.g. next/link. It receives href, className and the rest. */\n  as?: React.ElementType\n  /** Text for built-in controls and screen readers; pass translations here. */\n  labels?: Partial<LinkLabels>\n}\n\nconst CSS = `\n.pc-link{--pc-c:var(--primary);--pc-fg:var(--primary-foreground);-webkit-tap-highlight-color:transparent}\n.pc-link[data-tone=neutral]{--pc-c:var(--foreground);--pc-fg:var(--background)}\n.pc-link[data-tone=success]{--pc-c:oklch(0.53 0.13 155);--pc-fg:#fff}\n.pc-link[data-tone=warning]{--pc-c:oklch(0.75 0.16 70);--pc-fg:oklch(0.25 0.05 70)}\n.pc-link[data-tone=danger]{--pc-c:oklch(0.56 0.21 27);--pc-fg:#fff}\n.pc-link[data-tone=info]{--pc-c:oklch(0.55 0.17 250);--pc-fg:#fff}\n.dark .pc-link[data-tone=success]{--pc-c:oklch(0.7 0.16 155);--pc-fg:oklch(0.2 0.05 155)}\n.dark .pc-link[data-tone=danger]{--pc-c:oklch(0.68 0.2 25);--pc-fg:oklch(0.2 0.05 25)}\n.dark .pc-link[data-tone=info]{--pc-c:oklch(0.7 0.15 245);--pc-fg:oklch(0.2 0.05 245)}\n.pc-link{--pc-tint:color-mix(in oklab,var(--pc-c) 14%,transparent);--pc-ink:color-mix(in oklab,var(--pc-c) 82%,var(--foreground))}\n.pc-link[data-tone=warning]{--pc-ink:color-mix(in oklab,var(--pc-c) 62%,var(--foreground))}\n.pc-link[data-tone=inherit]{--pc-c:currentColor;--pc-ink:currentColor;--pc-tint:color-mix(in oklab,currentColor 14%,transparent)}\n.pc-link[data-tone=muted]{--pc-c:var(--muted-foreground);--pc-ink:var(--muted-foreground)}\n\n.pc-link{color:var(--pc-ink);text-decoration:none;cursor:pointer;border-radius:.2em;outline:none;transition:color .2s}\n.pc-link[data-tone=muted]:hover{color:var(--foreground)}\n.pc-link:focus-visible{outline:2px solid color-mix(in oklab,var(--pc-c) 55%,transparent);outline-offset:2px}\n.pc-link{text-decoration-thickness:max(1px,.07em);text-underline-offset:.24em;text-decoration-style:var(--pc-deco,solid)}\n.pc-link[data-decoration=dotted]{--pc-deco:dotted}\n.pc-link[data-decoration=dashed]{--pc-deco:dashed}\n.pc-link[data-decoration=wavy]{--pc-deco:wavy;text-underline-offset:.28em}\n.pc-link[data-underline=always]{text-decoration-line:underline;text-decoration-color:color-mix(in oklab,currentColor 40%,transparent);transition:text-decoration-color .2s,color .2s}\n.pc-link[data-underline=always]:hover{text-decoration-color:currentColor}\n.pc-link[data-underline=hover]:hover{text-decoration-line:underline}\n\n.pc-link[data-underline=slide],.pc-link[data-underline=grow-center]{background-image:linear-gradient(currentColor,currentColor);background-repeat:no-repeat;background-size:0% max(1px,.075em);background-position:100% 100%;padding-bottom:.08em;-webkit-box-decoration-break:clone;box-decoration-break:clone;transition:background-size .38s var(--pc-ease-out),color .2s}\n.pc-link[data-underline=slide]:hover,.pc-link[data-underline=slide]:focus-visible{background-size:100% max(1px,.075em);background-position:0 100%}\n.pc-link[data-underline=slide]:dir(rtl){background-position:0 100%}\n.pc-link[data-underline=slide]:dir(rtl):hover,.pc-link[data-underline=slide]:dir(rtl):focus-visible{background-position:100% 100%}\n.pc-link[data-underline=grow-center]{background-position:50% 100%}\n.pc-link[data-underline=grow-center]:hover,.pc-link[data-underline=grow-center]:focus-visible{background-size:100% max(1px,.075em)}\n.pc-link[data-underline=highlight]{background-image:linear-gradient(color-mix(in oklab,var(--pc-c) 22%,transparent),color-mix(in oklab,var(--pc-c) 22%,transparent));background-repeat:no-repeat;background-size:100% .14em;background-position:0 100%;padding:0 .12em;margin:0 -.12em;-webkit-box-decoration-break:clone;box-decoration-break:clone;transition:background-size .3s var(--pc-ease-out),color .2s}\n.pc-link[data-underline=highlight]:hover,.pc-link[data-underline=highlight]:focus-visible{background-size:100% 100%}\n.pc-link[data-tone=inherit][data-underline=highlight],.pc-link[data-tone=muted][data-underline=highlight]{background-image:linear-gradient(color-mix(in oklab,currentColor 16%,transparent),color-mix(in oklab,currentColor 16%,transparent))}\n\n.pc-link-icon{display:inline-flex;vertical-align:-.12em;margin-inline-end:.3em}\n.pc-link-icon>svg{width:1em;height:1em}\n.pc-link-arrow,.pc-link-ext{display:inline-block;width:.85em;height:.85em;margin-inline-start:.22em;vertical-align:-.06em;transition:transform .25s var(--pc-ease-out)}\n.pc-link-ext{width:.75em;height:.75em;opacity:.7;vertical-align:.02em}\n.pc-link[data-underline=arrow]:hover .pc-link-arrow,.pc-link[data-underline=arrow]:focus-visible .pc-link-arrow{transform:translateX(.22em)}\n.pc-link-arrow:dir(rtl){transform:scaleX(-1)}\n.pc-link[data-underline=arrow]:hover .pc-link-arrow:dir(rtl),.pc-link[data-underline=arrow]:focus-visible .pc-link-arrow:dir(rtl){transform:translateX(-.22em) scaleX(-1)}\n.pc-link:hover .pc-link-ext{transform:translate(.1em,-.1em);opacity:1}\n.pc-link-ext:dir(rtl){transform:scaleX(-1)}\n.pc-link:hover .pc-link-ext:dir(rtl){transform:translate(-.1em,-.1em) scaleX(-1)}\n.pc-link-nowrap{white-space:nowrap}\n@media (prefers-reduced-motion:reduce){\n  .pc-link,.pc-link *{transition:none!important}\n}\n`\n\nconst WEIGHTS: Record<LinkWeight, string> = { inherit: \"\", normal: \"font-normal\", medium: \"font-medium\", semibold: \"font-semibold\", bold: \"font-bold\" }\nconst SIZES: Record<LinkSize, string> = { inherit: \"\", xs: \"text-xs\", sm: \"text-sm\", base: \"text-base\", lg: \"text-lg\" }\n\nconst isAbsolute = (href?: string) => !!href && /^(https?:)?\\/\\//i.test(href)\n\n/** Keeps the trailing icon glued to the last word so it never wraps onto its own line. */\nfunction glue(children: React.ReactNode, icon: React.ReactNode) {\n  if (typeof children !== \"string\")\n    return (\n      <>\n        {children}\n        {icon}\n      </>\n    )\n  const i = children.trimEnd().lastIndexOf(\" \")\n  if (i < 0)\n    return (\n      <span className=\"pc-link-nowrap\">\n        {children}\n        {icon}\n      </span>\n    )\n  return [\n    children.slice(0, i + 1),\n    <span key=\"last\" className=\"pc-link-nowrap\">\n      {children.slice(i + 1)}\n      {icon}\n    </span>,\n  ]\n}\n\nexport function Link({\n  underline = \"hover\",\n  decoration = \"solid\",\n  tone = \"primary\",\n  weight = \"medium\",\n  size = \"inherit\",\n  external,\n  externalIcon = true,\n  iconLeft,\n  as,\n  href,\n  target,\n  rel,\n  className,\n  children,\n  labels,\n  ...props\n}: LinkProps) {\n  const l = useLabels(\"link\", DEFAULT_LABELS, labels)\n  const Comp = (as ?? \"a\") as React.ElementType\n  const ext = external ?? isAbsolute(href)\n  const trailing =\n    underline === \"arrow\" ? (\n      <svg key=\"arrow\" className=\"pc-link-arrow\" viewBox=\"0 0 16 16\" fill=\"none\" aria-hidden=\"true\">\n        <path d=\"M3 8h9.5M8.5 4l4 4-4 4\" stroke=\"currentColor\" strokeWidth=\"1.75\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n      </svg>\n    ) : ext && externalIcon ? (\n      <svg key=\"ext\" className=\"pc-link-ext\" viewBox=\"0 0 16 16\" fill=\"none\" aria-hidden=\"true\">\n        <path d=\"M5 11 11 5M6 5h5v5\" stroke=\"currentColor\" strokeWidth=\"1.75\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n      </svg>\n    ) : null\n\n  return (\n    <>\n      <GooduiTokens />\n      <style href=\"pc-link\" precedence=\"default\">\n        {CSS}\n      </style>\n      <Comp\n        data-slot=\"link\"\n        data-underline={underline}\n        data-decoration={decoration}\n        data-tone={tone}\n        href={href}\n        target={target ?? (ext ? \"_blank\" : undefined)}\n        rel={rel ?? (ext ? \"noopener noreferrer\" : undefined)}\n        className={cn(\"pc-link w-fit\", WEIGHTS[weight], SIZES[size], className)}\n        {...props}\n      >\n        {iconLeft && (\n          <span className=\"pc-link-icon\" aria-hidden=\"true\">\n            {iconLeft}\n          </span>\n        )}\n        {trailing ? glue(children, trailing) : children}\n        {ext && <span className=\"sr-only\">{\" \" + l.newTab}</span>}\n      </Comp>\n    </>\n  )\n}\n\n/** Alias for when `Link` clashes with next/link in the same file. */\nexport { Link as TextLink }\n",
      "type": "registry:component",
      "target": "components/goodui/link.tsx"
    }
  ],
  "categories": [
    "components",
    "core"
  ],
  "type": "registry:component"
}