{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "text",
  "title": "Text",
  "description": "Every body-copy role in one primitive: paragraph, lead, small, caption, overline, eyebrow pill, quote with attribution and inline code, with tones, readable measures, truncate or line clamp, and on-view entrances.",
  "dependencies": [],
  "registryDependencies": [
    "https://goodui.dev/r/goodui-motion.json"
  ],
  "files": [
    {
      "path": "registry/components/core/text.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { cn } from \"@/lib/utils\"\nimport { GooduiTokens } from \"@/lib/goodui-motion\"\n\n/*\n * One text primitive, independent layers: every axis combines with every other.\n *   variant    paragraph, lead, small, caption, overline, eyebrow, quote, code\n *   tone       auto (the variant's natural color), default, muted, or an accent tone\n *   size/weight/font  \"auto\" keeps the variant's choice\n *   measure    readable line length          clamp      truncate or clamp to N lines\n *   animation  entrance on view (once)\n * <mark> inside any variant gets a tone marker. Fonts follow --font-serif / --font-mono when you set them.\n */\n\nexport type TextVariant = \"paragraph\" | \"lead\" | \"small\" | \"caption\" | \"overline\" | \"eyebrow\" | \"quote\" | \"code\"\nexport type TextTone = \"auto\" | \"default\" | \"muted\" | \"primary\" | \"neutral\" | \"success\" | \"warning\" | \"danger\" | \"info\"\nexport type TextSize = \"auto\" | \"xs\" | \"sm\" | \"base\" | \"lg\" | \"xl\" | \"2xl\"\nexport type TextWeight = \"auto\" | \"normal\" | \"medium\" | \"semibold\" | \"bold\"\nexport type TextFont = \"auto\" | \"sans\" | \"serif\" | \"mono\"\nexport type TextMeasure = \"none\" | \"narrow\" | \"normal\" | \"wide\"\nexport type TextAlign = \"start\" | \"center\" | \"end\" | \"justify\"\nexport type TextAnimation = \"none\" | \"fade-in\" | \"fade-up\" | \"blur-in\" | \"reveal\"\nexport type TextElement = \"p\" | \"span\" | \"div\" | \"blockquote\" | \"figcaption\" | \"label\" | \"code\" | \"small\" | \"li\" | \"strong\" | \"em\"\n\nexport type TextProps = React.HTMLAttributes<HTMLElement> & {\n  /** Text role; sets the default element, size, weight, font and color. */\n  variant?: TextVariant\n  /** Element to render. Defaults per variant (p, blockquote for quote, code for code). */\n  as?: TextElement\n  /** Color: auto keeps the variant's color; default and muted use theme text colors; the rest are accent tones (also color <mark>). */\n  tone?: TextTone\n  /** Font size; auto uses the variant's. */\n  size?: TextSize\n  /** Font weight; auto uses the variant's. */\n  weight?: TextWeight\n  /** Font family; serif and mono use --font-serif and --font-mono. auto uses the variant's. */\n  font?: TextFont\n  /** Max line length: narrow 45ch, normal 65ch, wide 80ch. */\n  measure?: TextMeasure\n  /** Text alignment (start and end follow the writing direction). */\n  align?: TextAlign\n  /** Single line with an ellipsis. */\n  truncate?: boolean\n  /** Clamp to N lines with an ellipsis. */\n  lineClamp?: number | \"none\" | \"1\" | \"2\" | \"3\" | \"4\" | \"5\" | \"6\"\n  /** Entrance animation, played once when the text scrolls into view. */\n  animation?: TextAnimation\n  /** Quote variant: who said it. */\n  attribution?: React.ReactNode\n  ref?: React.Ref<HTMLElement>\n}\n\nconst CSS = `\n.pc-text{--pc-c:var(--primary);--pc-fg:var(--primary-foreground);margin:0}\n.pc-text[data-tone=neutral]{--pc-c:var(--foreground);--pc-fg:var(--background)}\n.pc-text[data-tone=success]{--pc-c:oklch(0.53 0.13 155);--pc-fg:#fff}\n.pc-text[data-tone=warning]{--pc-c:oklch(0.75 0.16 70);--pc-fg:oklch(0.25 0.05 70)}\n.pc-text[data-tone=danger]{--pc-c:oklch(0.56 0.21 27);--pc-fg:#fff}\n.pc-text[data-tone=info]{--pc-c:oklch(0.55 0.17 250);--pc-fg:#fff}\n.dark .pc-text[data-tone=success]{--pc-c:oklch(0.7 0.16 155);--pc-fg:oklch(0.2 0.05 155)}\n.dark .pc-text[data-tone=danger]{--pc-c:oklch(0.68 0.2 25);--pc-fg:oklch(0.2 0.05 25)}\n.dark .pc-text[data-tone=info]{--pc-c:oklch(0.7 0.15 245);--pc-fg:oklch(0.2 0.05 245)}\n.pc-text{--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-text[data-tone=warning]{--pc-ink:color-mix(in oklab,var(--pc-c) 62%,var(--foreground))}\n\n.pc-text[data-ink=default]{color:var(--foreground)}\n.pc-text[data-ink=muted]{color:var(--muted-foreground)}\n.pc-text[data-ink=tone]{color:var(--pc-ink)}\n.pc-text[data-font=serif]{font-family:var(--font-serif,ui-serif,\"Iowan Old Style\",\"Palatino Linotype\",Palatino,Georgia,serif)}\n.pc-text[data-font=mono]{font-family:var(--font-mono,ui-monospace,SFMono-Regular,Menlo,Consolas,monospace)}\n.pc-text mark{background:color-mix(in oklab,var(--pc-c) 18%,transparent);color:inherit;border-radius:.25em;padding:.05em .2em;-webkit-box-decoration-break:clone;box-decoration-break:clone}\n.pc-text[data-tone=default] mark,.pc-text[data-tone=auto] mark,.pc-text[data-tone=muted] mark{background:color-mix(in oklab,oklch(0.8 0.16 85) 45%,transparent)}\n.dark .pc-text[data-tone=default] mark,.dark .pc-text[data-tone=auto] mark,.dark .pc-text[data-tone=muted] mark{background:color-mix(in oklab,oklch(0.8 0.16 85) 30%,transparent)}\n.pc-text code{font-family:var(--font-mono,ui-monospace,SFMono-Regular,Menlo,Consolas,monospace);font-size:.875em;background:var(--muted);border-radius:.3em;padding:.1em .35em}\n/* Muted text on a highlight or code chip drops below 4.5:1, so those runs use a stronger ink. */\n.pc-text[data-variant=code][data-ink=muted],.pc-text[data-ink=muted] :is(mark,code){color:color-mix(in oklab,var(--muted-foreground) 55%,var(--foreground))}\n\n.pc-text[data-variant=overline]{display:flex;align-items:center;gap:.75em}\n.pc-text[data-variant=overline]::before{content:\"\";width:1.5em;height:1.5px;border-radius:1px;background:currentColor;opacity:.55;flex:none}\n.pc-text[data-variant=overline][data-align=center]{justify-content:center}\n.pc-text[data-variant=overline][data-align=end]{justify-content:flex-end}\n.pc-text[data-variant=eyebrow]{display:inline-flex;align-items:center;gap:.5em;width:fit-content;max-width:100%;border:1px solid color-mix(in oklab,var(--pc-c) 22%,var(--border));background:color-mix(in oklab,var(--pc-c) 6%,var(--background));border-radius:999px;padding-block:.3em;padding-inline:.65em .8em;box-shadow:0 1px 2px rgb(0 0 0/.04)}\n.pc-text[data-variant=eyebrow]::before{content:\"\";width:.45em;height:.45em;border-radius:999px;background:var(--pc-c);box-shadow:0 0 0 .2em color-mix(in oklab,var(--pc-c) 20%,transparent);flex:none}\n.pc-text[data-variant=eyebrow][data-tone=auto]::before,.pc-text[data-variant=eyebrow][data-tone=default]::before,.pc-text[data-variant=eyebrow][data-tone=muted]::before{background:oklch(0.65 0.17 155);box-shadow:0 0 0 .2em color-mix(in oklab,oklch(0.65 0.17 155) 22%,transparent)}\n.pc-text[data-variant=quote]{position:relative;border-inline-start:3px solid color-mix(in oklab,var(--pc-c) 70%,transparent);padding-inline-start:1.1em}\n.pc-text[data-variant=quote][data-tone=auto],.pc-text[data-variant=quote][data-tone=default],.pc-text[data-variant=quote][data-tone=muted]{border-inline-start-color:var(--border)}\n.pc-text-cite{display:block;margin-top:.6em;font-size:.8125rem;font-style:normal;font-family:var(--font-sans,ui-sans-serif,system-ui,sans-serif);color:var(--muted-foreground)}\n.pc-text-cite::before{content:\"— \"}\n.pc-text[data-variant=code]{background:color-mix(in oklab,var(--pc-c) 8%,var(--muted));border:1px solid color-mix(in oklab,var(--pc-c) 14%,var(--border));border-radius:.35em;padding:.12em .4em;-webkit-box-decoration-break:clone;box-decoration-break:clone}\n.pc-text[data-variant=code][data-tone=auto],.pc-text[data-variant=code][data-tone=default],.pc-text[data-variant=code][data-tone=muted]{background:var(--muted);border-color:var(--border)}\n\n@media (prefers-reduced-motion:no-preference){\n  .pc-text[data-inview=false]:not([data-anim=none]){opacity:0}\n  .pc-text[data-inview=true][data-anim=fade-in]{animation:pc-text-fade .7s ease-out both}\n  .pc-text[data-inview=true][data-anim=fade-up]{animation:pc-text-up .7s var(--pc-ease-out) both}\n  .pc-text[data-inview=true][data-anim=blur-in]{animation:pc-text-blur .8s var(--pc-ease-out) both}\n  .pc-text[data-inview=true][data-anim=reveal]{animation:pc-text-reveal .9s var(--pc-ease-in-out) both}\n  .pc-text[data-inview=true][data-anim=reveal]:dir(rtl){animation-name:pc-text-reveal-rtl}\n}\n@keyframes pc-text-fade{from{opacity:0}to{opacity:1}}\n@keyframes pc-text-up{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:none}}\n@keyframes pc-text-blur{from{opacity:0;filter:blur(8px)}to{opacity:1;filter:none}}\n@keyframes pc-text-reveal{from{opacity:.2;clip-path:inset(0 100% 0 0)}to{opacity:1;clip-path:inset(0 0 0 0)}}\n@keyframes pc-text-reveal-rtl{from{opacity:.2;clip-path:inset(0 0 0 100%)}to{opacity:1;clip-path:inset(0 0 0 0)}}\n`\n\ntype VariantDefaults = { as: TextElement; size: Exclude<TextSize, \"auto\">; weight: Exclude<TextWeight, \"auto\">; font: Exclude<TextFont, \"auto\">; ink: \"inherit\" | \"default\" | \"muted\" | \"tone\"; extra: string }\nconst VARIANTS: Record<TextVariant, VariantDefaults> = {\n  paragraph: { as: \"p\", size: \"base\", weight: \"normal\", font: \"sans\", ink: \"inherit\", extra: \"leading-7\" },\n  lead: { as: \"p\", size: \"xl\", weight: \"normal\", font: \"sans\", ink: \"muted\", extra: \"leading-relaxed tracking-[-0.01em]\" },\n  small: { as: \"p\", size: \"sm\", weight: \"normal\", font: \"sans\", ink: \"inherit\", extra: \"leading-6\" },\n  caption: { as: \"p\", size: \"xs\", weight: \"normal\", font: \"sans\", ink: \"muted\", extra: \"leading-5\" },\n  overline: { as: \"p\", size: \"xs\", weight: \"semibold\", font: \"sans\", ink: \"muted\", extra: \"uppercase tracking-[0.14em] leading-5\" },\n  eyebrow: { as: \"p\", size: \"xs\", weight: \"medium\", font: \"sans\", ink: \"default\", extra: \"leading-5\" },\n  quote: { as: \"blockquote\", size: \"lg\", weight: \"normal\", font: \"serif\", ink: \"default\", extra: \"leading-relaxed italic\" },\n  code: { as: \"code\", size: \"sm\", weight: \"normal\", font: \"mono\", ink: \"default\", extra: \"leading-6\" },\n}\nconst SIZES: Record<Exclude<TextSize, \"auto\">, string> = {\n  xs: \"text-xs\",\n  sm: \"text-sm\",\n  base: \"text-base\",\n  lg: \"text-lg\",\n  xl: \"text-lg sm:text-xl\",\n  \"2xl\": \"text-xl sm:text-2xl\",\n}\nconst WEIGHTS: Record<Exclude<TextWeight, \"auto\">, string> = { normal: \"font-normal\", medium: \"font-medium\", semibold: \"font-semibold\", bold: \"font-bold\" }\nconst MEASURES: Record<TextMeasure, string> = { none: \"\", narrow: \"max-w-[45ch]\", normal: \"max-w-[65ch]\", wide: \"max-w-[80ch]\" }\nconst ALIGNS: Record<TextAlign, string> = { start: \"text-start\", center: \"text-center\", end: \"text-end\", justify: \"text-justify hyphens-auto\" }\n\nfunction useInView(ref: React.RefObject<HTMLElement | null>, enabled: boolean) {\n  const [inView, setInView] = React.useState(false)\n  React.useEffect(() => {\n    if (!enabled || inView) return\n    const el = ref.current\n    if (!el) return\n    if (typeof IntersectionObserver === \"undefined\") return setInView(true)\n    const io = new IntersectionObserver(\n      ([e]) => {\n        if (e?.isIntersecting) {\n          setInView(true)\n          io.disconnect()\n        }\n      },\n      { threshold: 0.2 },\n    )\n    io.observe(el)\n    return () => io.disconnect()\n  }, [ref, enabled, inView])\n  return inView\n}\n\nexport function Text({\n  variant = \"paragraph\",\n  as,\n  tone = \"auto\",\n  size = \"auto\",\n  weight = \"auto\",\n  font = \"auto\",\n  measure = \"none\",\n  align = \"start\",\n  truncate,\n  lineClamp = \"none\",\n  animation = \"none\",\n  attribution,\n  className,\n  style,\n  children,\n  ref: userRef,\n  ...props\n}: TextProps) {\n  const ref = React.useRef<HTMLElement>(null)\n  const animated = animation !== \"none\"\n  const inView = useInView(ref, animated)\n  const setRef = React.useCallback(\n    (el: HTMLElement | null) => {\n      ref.current = el\n      if (typeof userRef === \"function\") userRef(el)\n      else if (userRef) (userRef as React.RefObject<HTMLElement | null>).current = el\n    },\n    [userRef],\n  )\n\n  const d = VARIANTS[variant]\n  const Tag = (as ?? d.as) as React.ElementType\n  const ink = tone === \"auto\" ? d.ink : tone === \"default\" || tone === \"muted\" ? tone : \"tone\"\n  const clamp = lineClamp === \"none\" ? 0 : Number(lineClamp)\n\n  return (\n    <>\n      <GooduiTokens />\n      <style href=\"pc-text\" precedence=\"default\">\n        {CSS}\n      </style>\n      <Tag\n        ref={setRef}\n        data-slot=\"text\"\n        data-variant={variant}\n        data-tone={tone}\n        data-ink={ink}\n        data-font={font === \"auto\" ? d.font : font}\n        data-align={align}\n        data-anim={animation}\n        data-inview={animated ? inView : undefined}\n        className={cn(\n          \"pc-text\",\n          SIZES[size === \"auto\" ? d.size : size],\n          WEIGHTS[weight === \"auto\" ? d.weight : weight],\n          d.extra,\n          MEASURES[measure],\n          ALIGNS[align],\n          truncate && \"truncate\",\n          clamp > 0 && !truncate && \"overflow-hidden [display:-webkit-box] [-webkit-box-orient:vertical]\",\n          className,\n        )}\n        style={clamp > 0 && !truncate ? ({ WebkitLineClamp: clamp, ...style } as React.CSSProperties) : style}\n        {...props}\n      >\n        {children}\n        {variant === \"quote\" && attribution != null && <cite className=\"pc-text-cite\">{attribution}</cite>}\n      </Tag>\n    </>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/goodui/text.tsx"
    }
  ],
  "categories": [
    "components",
    "core"
  ],
  "type": "registry:component"
}