{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "sf-text", "title": "SF Text", "description": "Polymorphic text component with semantic typography aliases. FRAME layer.", "files": [ { "path": "components/sf/sf-text.tsx", "content": "import { cn } from \"@/lib/utils\";\nimport React from \"react\";\n\nexport type TextVariant = \"heading-1\" | \"heading-2\" | \"heading-3\" | \"body\" | \"small\";\n\ntype TextElement =\n | \"h1\"\n | \"h2\"\n | \"h3\"\n | \"h4\"\n | \"h5\"\n | \"h6\"\n | \"p\"\n | \"span\"\n | \"label\";\n\nconst variantClassMap: Record = {\n \"heading-1\": \"text-heading-1\",\n \"heading-2\": \"text-heading-2\",\n \"heading-3\": \"text-heading-3\",\n body: \"text-body\",\n small: \"text-small\",\n};\n\nconst defaultElementMap: Record = {\n \"heading-1\": \"h1\",\n \"heading-2\": \"h2\",\n \"heading-3\": \"h3\",\n body: \"p\",\n small: \"span\",\n};\n\ninterface SFTextProps extends React.HTMLAttributes {\n variant: TextVariant;\n as?: TextElement;\n className?: string;\n}\n\n/**\n * Semantic text primitive — FRAME layer typography enforcer.\n *\n * Maps semantic variants to typography alias classes (text-heading-1 etc.)\n * defined in globals.css. Defaults to the appropriate HTML element for each\n * variant (h1/h2/h3 for headings, p for body, span for small) but accepts\n * `as` for override. Polymorphic — ref is cast to React.Ref per\n * TypeScript forwardRef polymorphic limitation.\n *\n * @param variant - Semantic text style. \"heading-1\" | \"heading-2\" | \"heading-3\" | \"body\" | \"small\"\n * @param as - Override rendered element tag. Defaults: h1/h2/h3/p/span per variant\n * @param className - Merged via cn() after variant class\n *\n * @example\n * Signal Frame\n * Inline body text\n */\nconst SFText = React.forwardRef(\n function SFText({ variant, as, className, ...props }, ref) {\n const Tag = as ?? defaultElementMap[variant];\n return (\n }\n className={cn(variantClassMap[variant], className)}\n {...(props as React.HTMLAttributes)}\n />\n );\n }\n);\n\nSFText.displayName = \"SFText\";\n\nexport { SFText };\n", "type": "registry:ui" } ], "meta": { "layer": "frame", "pattern": "C" }, "type": "registry:ui" }