{"$schema":"https://ui.shadcn.com/schema/registry-item.json","author":"Hairline UI","meta":{"license":"MIT"},"name":"icon-base","type":"registry:component","title":"Hairline icon base","description":"The renderer every Hairline icon imports: size, outline or solid, the 16 px drawing at small sizes, and active, which fills an icon in when it is selected.","files":[{"path":"registry/components/icons/icon-base.tsx","type":"registry:component","target":"components/icons/icon-base.tsx","content":"// Hairline Icons · MIT License\n// Copyright (c) 2026 Hairline UI · https://hairlineui.com/icons\n\nimport { useId, type SVGProps } from 'react';\n\nexport type IconVariant = 'outline' | 'solid';\n\nexport interface IconProps extends Omit<SVGProps<SVGSVGElement>, 'children' | 'dangerouslySetInnerHTML'> {\n  /** Rendered size in px. 17 and below use the drawing fitted to 16 px; above 20 the line grows slower than the icon. */\n  size?: number;\n  /** Outline (default) or Solid, the filled version for selected and pressed states. */\n  variant?: IconVariant;\n  /**\n   * The selected state, with motion: the icon fills from outline to solid when this turns true and empties when it\n   * turns false (about 150 ms, instant with reduced motion). Takes over from variant. Mark the state on the control as\n   * well, e.g. aria-current on a nav link or aria-pressed on a toggle.\n   */\n  active?: boolean;\n  /** Accessible name. Without it the icon is decorative and hidden from screen readers. */\n  label?: string;\n}\n\n/** The four drawings of one icon: outline and solid, at 20 px and fitted to 16 px. */\nexport interface IconData {\n  o20: string;\n  s20: string;\n  o16: string;\n  s16: string;\n}\n\n/** Line weight in viewBox units: 1.5 at 16, 1.75 at 20, and above 20 it grows slower than the icon (about 3 px at 48). */\nexport const iconStroke = (size: number) => (size <= 17 ? 1.5 : size > 20 ? 1.75 * Math.pow(size / 20, -0.4) : 1.75);\n\n/**\n * The fill between outline and solid, shared by every icon (React 19 puts it in the head once). Going solid, the fill\n * arrives first and the outline leaves under it; going back, the outline returns first and the fill leaves over it, so\n * the line never thins halfway.\n */\nconst ACTIVE_CSS = \".hl-sel>.hl-o{transition:opacity 70ms linear}.hl-sel>.hl-s{opacity:0;transition:opacity 120ms cubic-bezier(.22,1,.36,1) 30ms}.hl-sel[data-active]>.hl-s{opacity:1;transition-delay:0ms}.hl-sel[data-active]>.hl-o{opacity:0;transition-delay:80ms}@media (prefers-reduced-motion:reduce){.hl-sel>g{transition:none!important}}\";\n\n/** Draws one Hairline icon. Mask ids are made unique per instance, so cut-outs work wherever an icon appears twice. */\nexport function HairlineIcon({ data, size = 20, variant = 'outline', active, label, className, ...rest }: IconProps & { data: IconData }) {\n  const uid = useId().replace(/[^a-zA-Z0-9_-]/g, '');\n  const small = size <= 17;\n  const grid = small ? 16 : 20;\n  const outline = small ? data.o16 : data.o20;\n  const solid = small ? data.s16 : data.s20;\n  // line glyphs (arrows, x, plus) have no inside to fill, so they have nothing to fade\n  const fades = active !== undefined && solid !== outline;\n  const body = fades\n    ? `<g class=\"hl-o\">${outline.replaceAll('__ID__', `hl${uid}o-`)}</g><g class=\"hl-s\">${solid.replaceAll('__ID__', `hl${uid}s-`)}</g>`\n    : ((active ?? variant === 'solid') ? solid : outline).replaceAll('__ID__', `hl${uid}-`);\n  const svg = (\n    <svg\n      xmlns=\"http://www.w3.org/2000/svg\"\n      viewBox={`0 0 ${grid} ${grid}`}\n      width={size}\n      height={size}\n      fill=\"none\"\n      stroke=\"currentColor\"\n      strokeWidth={+iconStroke(size).toFixed(3)}\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n      role={label ? 'img' : undefined}\n      aria-label={label}\n      aria-hidden={label ? undefined : true}\n      focusable=\"false\"\n      className={fades ? (className ? `hl-sel ${className}` : 'hl-sel') : className}\n      data-active={fades && active ? '' : undefined}\n      {...rest}\n      dangerouslySetInnerHTML={{ __html: body }}\n    />\n  );\n  if (!fades) return svg;\n  return (\n    <>\n      <style href=\"hairline-icon-active\" precedence=\"default\">\n        {ACTIVE_CSS}\n      </style>\n      {svg}\n    </>\n  );\n}\n"}],"docs":"All icons: https://hairlineui.com/icons. MIT licensed."}