{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "heading",
  "title": "Heading",
  "description": "A section title, `<h1>` to `<h6>`, in the theme's foreground color.",
  "registryDependencies": [
    "@ouro/lib-appearance-hints",
    "@ouro/lib-class-name-check",
    "@ouro/lib-cn",
    "@ouro/lib-dev",
    "@ouro/lib-env",
    "@ouro/lib-use-dev-messages",
    "@ouro/text"
  ],
  "files": [
    {
      "path": "registry/ouro/components/ouro/text/heading.tsx",
      "content": "\"use client\";\n\nimport type { HTMLAttributes, JSX, ReactNode, Ref } from \"react\";\nimport { fontFor, sizeFor, toneFor } from \"@/registry/ouro/lib/ouro/appearance-hints\";\nimport { useAppearanceClassNameCheck } from \"@/registry/ouro/lib/ouro/class-name-check\";\nimport { cn } from \"@/registry/ouro/lib/ouro/cn\";\nimport { devThrow } from \"@/registry/ouro/lib/ouro/dev\";\nimport { useDevWarnings } from \"@/registry/ouro/lib/ouro/use-dev-messages\";\nimport { alignClasses, checkAlign, type TextAlign } from \"@/registry/ouro/components/ouro/text/text-styles\";\n\n/** A heading size from the theme's type scale. `display` is for a page's hero headline. */\nexport type HeadingSize = \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\" | \"display\";\n\n/** Props for {@link Heading}. */\nexport interface HeadingProps extends Omit<HTMLAttributes<HTMLHeadingElement>, \"color\" | \"className\" | \"children\"> {\n  /**\n   * Outline level: sets the tag (`level={2}` renders `<h2>`). Required, because\n   * the level is about document structure, not looks; use `size` to change how\n   * big it looks.\n   */\n  level: 1 | 2 | 3 | 4 | 5 | 6 | (number & { 'Use 1 to 6; size sets the look': never });\n  /**\n   * Visual size, independent of the level. `display` is the hero headline of a\n   * landing page, tightly set and larger from the `sm` breakpoint: `<Heading level={1} size=\"display\">`.\n   * Each size above `sm` is set tighter than the last. A theme whose `--font-heading` is a serif sets\n   * `--ouro-heading-tracking` below its default of `1`, such as `0.5`, to tighten by that share and\n   * keep more of the font's own spacing; `0` sets every size at the font's own spacing.\n   * @default derived from `level` (1 is `2xl`, 2 is `xl`, 3 is `lg`, 4 is `md`, 5 and 6 are `sm`)\n   * @claim \"derived from `level`\" registry/ouro/components/ouro/text/heading.test.tsx verify:testExists(registry/ouro/components/ouro/text/heading.test.tsx::Heading > derives a smaller default size for deeper levels)\n   * @claim \"Each size above `sm` is set tighter than the last\" registry/ouro/components/ouro/text/heading.test.tsx verify:testExists(registry/ouro/components/ouro/text/heading.test.tsx::Heading tracking > tightens as the text grows: none at body size, more at each larger size)\n   * @claim \"to tighten by that share\" registry/ouro/components/ouro/text/heading.test.tsx verify:testExists(registry/ouro/components/ouro/text/heading.test.tsx::Heading tracking > scales the tightening by the theme's --ouro-heading-tracking, so a serif heading font can keep its own spacing)\n   */\n  size?: HeadingSize | (string & { 'Use \"sm\", \"md\", \"lg\", \"xl\", \"2xl\" or, larger, \"display\"': never }) | undefined;\n  /**\n   * Cuts the heading to one line with an ellipsis, as a list row or a title bar needs. A heading\n   * otherwise balances its lines, which would wrap it again, so `truncate` drops the balancing.\n   * @default false\n   * @claim \"Cuts the heading to one line\" registry/ouro/components/ouro/text/heading.test.tsx verify:testExists(registry/ouro/components/ouro/text/heading.test.tsx::Heading > cuts to one line with an ellipsis with truncate, without balancing it back onto two)\n   */\n  truncate?: boolean | undefined;\n  /** Alignment in writing direction. @default inherited */\n  align?: TextAlign | (string & { 'Use \"start\", \"center\" or \"end\": left is \"start\", right is \"end\"': never }) | undefined;\n  /**\n   * Layout only: margins, width, grid placement (`mb-2`). Appearance classes\n   * warn in development; use `size` and `align`.\n   */\n  className?: string | undefined;\n  /** The heading text. */\n  children: ReactNode;\n  ref?: Ref<HTMLHeadingElement> | undefined;\n  /** Not a prop. The tag comes from `level`: `<Heading level={2}>`. */\n  as?: { 'Use <Heading level={2}>': never };\n  /** Not a prop. Headings use the theme's foreground color; for colored text use `<Text tone=\"…\">`. */\n  color?: { 'Use <Text tone=\"primary\">': never };\n}\n\n// Each size tightens by its own step times the theme's --ouro-heading-tracking (1 unless set), so a\n// serif heading font, whose letters already sit close, can keep more of its own spacing.\nconst sizes = {\n  sm: \"text-base\",\n  md: \"text-lg tracking-[calc(-0.01em*var(--ouro-heading-tracking,1))]\",\n  lg: \"text-xl tracking-[calc(-0.015em*var(--ouro-heading-tracking,1))]\",\n  xl: \"text-2xl tracking-[calc(-0.02em*var(--ouro-heading-tracking,1))]\",\n  \"2xl\": \"text-3xl tracking-[calc(-0.025em*var(--ouro-heading-tracking,1))]\",\n  display: \"text-[2.5rem] leading-[1.05] tracking-[calc(-0.035em*var(--ouro-heading-tracking,1))] sm:text-6xl sm:leading-[1.02]\",\n} as const;\n\nconst sizeByLevel = { 1: \"2xl\", 2: \"xl\", 3: \"lg\", 4: \"md\", 5: \"sm\", 6: \"sm\" } as const;\n\nfunction headingHint(token: string): string {\n  if (/^text-[4-9]xl$/.test(token)) return 'size=\"display\"';\n  const size = sizeFor(token, [\"sm\", \"sm\", \"sm\", \"md\", \"lg\", \"xl\", \"2xl\"]);\n  if (size) return `size=\"${size}\"`;\n  if (token.startsWith(\"font-\")) return fontFor(\"Heading\", token);\n  return \"<Heading level={2}>…</Heading>\";\n}\n\n/**\n * A section title, `<h1>` to `<h6>`, in the theme's foreground color. `level` sets\n * the tag and a default size; `size` changes only the look.\n *\n * Use `Text` instead for body copy, and for a dialog or sheet title use its\n * `title` prop, which also labels it for assistive technology.\n *\n * @group Text\n * @see https://ui.ouroboros.bot/docs/heading\n *\n * @example\n * <Heading level={1}>Recipes</Heading>\n * <Heading level={2} size=\"lg\">Ingredients</Heading>\n * <Heading level={1} size=\"display\">Dinner, sorted</Heading>\n * <Heading level={3} truncate>{thread.subject}</Heading>\n */\nexport function Heading(props: HeadingProps): JSX.Element {\n  const { level: levelProp, size: sizeProp, align: alignProp, truncate, className, ref, color, as, ...rest } = props;\n  const level = levelProp as keyof typeof sizeByLevel;\n  const [align, alignWarning] = checkAlign(\"Heading\", alignProp);\n  if (!(level in sizeByLevel) || typeof level !== \"number\") {\n    devThrow(\n      \"Heading\",\n      `level must be 1, 2, 3, 4, 5 or 6, got ${JSON.stringify(level)}`,\n      process.env.NODE_ENV !== \"production\" ? \"<Heading level={2}>\" : /* istanbul ignore next @preserve -- production only */ \"\",\n    );\n  }\n  // A size that is not one of Ouro UI's (a type error) warns and renders the level's default.\n  const size = sizeProp !== undefined && Object.hasOwn(sizes, sizeProp) ? (sizeProp as HeadingSize) : sizeByLevel[level];\n  useAppearanceClassNameCheck(\n    \"Heading\",\n    className,\n    process.env.NODE_ENV !== \"production\" ? headingHint : /* istanbul ignore next @preserve -- production only */ \"\",\n    process.env.NODE_ENV !== \"production\" ? 'align=\"center\"' : /* istanbul ignore next @preserve -- production only */ undefined,\n  );\n  useDevWarnings(\n    \"Heading\",\n    process.env.NODE_ENV !== \"production\"\n      ? () => [\n          alignWarning,\n          color !== undefined && [\n            \"color is not a prop; headings use the theme foreground color\",\n            `<Text tone=\"${toneFor(`text-${String(color)}`)}\">`,\n          ],\n          sizeProp !== undefined &&\n            size !== sizeProp && [\n              `size=\"${String(sizeProp)}\" is not a size; use ${Object.keys(sizes).map((name) => `\"${name}\"`).join(\", \")}`,\n              `<Heading level={${level}} size=\"${/^\\d+xl$/.test(String(sizeProp)) ? \"display\" : sizeByLevel[level]}\">`,\n            ],\n          as !== undefined && [\n            \"as is not a prop; level sets the tag\",\n            `<Heading level={${/^h[1-6]$/.test(String(as)) ? String(as).slice(1) : 2}}>`,\n          ],\n        ]\n      : /* istanbul ignore next @preserve -- production only */ undefined,\n  );\n  const Tag = `h${level}` as const;\n  const classes = cn(\n    \"[@layer_ouro-reset]:m-0 font-[family-name:var(--font-heading,inherit)] font-semibold text-foreground\",\n    truncate ? \"truncate\" : \"text-balance\",\n    sizes[size],\n    align && alignClasses[align],\n    className,\n  );\n  return <Tag {...rest} ref={ref} data-ouro=\"heading\" className={classes} />;\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/text/heading.tsx"
    }
  ],
  "docs": "A section title, `<h1>` to `<h6>`, in the theme's foreground color. Import: import { Heading } from \"@/components/ouro/text/heading\", with @/components replaced by your components alias (aliases.components in components.json, such as ~/components). Also installed: text, the helpers they import in lib/ouro. Needs ouro-base in your stylesheet: add that item once per app, from the same place as this one, if you have not. Docs: https://ui.ouroboros.bot/docs/heading.md Ouro UI v1.3.257.",
  "type": "registry:ui"
}