{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "avatar",
  "type": "registry:ui",
  "title": "Avatar",
  "description": "Avatar is a circular visual identity for a user or entity with image, initials, or icon fallback.",
  "author": "Skrewww",
  "dependencies": [
    "@phosphor-icons/react"
  ],
  "registryDependencies": [
    "@skrewww/foundation"
  ],
  "docs": "Host requirements (assumed already present, not installed by this command): react, react-dom.",
  "files": [
    {
      "path": "components/ui/Avatar.tsx",
      "content": "/** @skrewww-component avatar */\n\"use client\";\n\nimport { User } from \"@phosphor-icons/react\";\nimport {\n  useCallback,\n  useState,\n  type ImgHTMLAttributes,\n  type SyntheticEvent,\n} from \"react\";\nimport { cn } from \"@/lib/cn\";\nimport styles from \"@/components/ui/avatar.module.css\";\n\nexport type AvatarSize = \"sm\" | \"md\" | \"lg\";\n\nexport type AvatarProps = Omit<ImgHTMLAttributes<HTMLImageElement>, \"children\"> & {\n  size?: AvatarSize;\n  src?: string;\n  alt?: string;\n  initials?: string;\n  /** Accessible name for initials or icon fallback when informative. */\n  label?: string;\n  /** When true, hides the avatar from assistive technology. */\n  decorative?: boolean;\n};\n\nexport function Avatar({\n  size = \"md\",\n  src,\n  alt,\n  initials,\n  label,\n  decorative = false,\n  className,\n  onError,\n  ...props\n}: AvatarProps) {\n  const [imageFailed, setImageFailed] = useState(false);\n  const showImage = Boolean(src) && !imageFailed;\n\n  const handleError = useCallback(\n    (event: SyntheticEvent<HTMLImageElement>) => {\n      setImageFailed(true);\n      onError?.(event);\n    },\n    [onError],\n  );\n\n  const imageAlt = decorative ? \"\" : alt ?? \"\";\n  const fallbackLabel = !decorative && !showImage ? label : undefined;\n\n  return (\n    <span\n      className={cn(styles.root, styles[size], className)}\n      data-fallback={showImage ? undefined : initials ? \"initials\" : \"icon\"}\n      aria-hidden={decorative || undefined}\n      aria-label={fallbackLabel}\n      role={fallbackLabel ? \"img\" : undefined}\n    >\n      {showImage ? (\n        // eslint-disable-next-line @next/next/no-img-element -- native img required for onError fallback\n        <img\n          {...props}\n          src={src}\n          alt={imageAlt}\n          className={styles.image}\n          onError={handleError}\n        />\n      ) : initials ? (\n        <span className={styles.initials} aria-hidden={fallbackLabel ? true : undefined}>\n          {initials.slice(0, 2).toUpperCase()}\n        </span>\n      ) : (\n        <User size={size === \"sm\" ? 16 : size === \"lg\" ? 28 : 20} aria-hidden=\"true\" />\n      )}\n    </span>\n  );\n}\n",
      "type": "registry:ui",
      "target": "~/components/ui/Avatar.tsx"
    },
    {
      "path": "components/ui/avatar.module.css",
      "content": ".root {\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n  flex-shrink: 0;\n  overflow: hidden;\n  border: 0;\n  background-color: var(--avatar-background);\n  background-image: var(--component-surface-gradient-overlay);\n  color: var(--avatar-text);\n  border-radius: var(--avatar-radius);\n  font-weight: 600;\n  line-height: 1;\n}\n\n.sm {\n  width: var(--avatar-size-sm);\n  height: var(--avatar-size-sm);\n  font-size: 0.75rem;\n}\n\n.md {\n  width: var(--avatar-size-md);\n  height: var(--avatar-size-md);\n  font-size: 0.875rem;\n}\n\n.lg {\n  width: var(--avatar-size-lg);\n  height: var(--avatar-size-lg);\n  font-size: 1rem;\n}\n\n.image {\n  width: 100%;\n  height: 100%;\n  object-fit: var(--avatar-image-fit);\n}\n\n.initials {\n  user-select: none;\n}\n\n/* Avatar identity shape stays circular regardless of global shape mode */\n[data-skrewww-shape] .root {\n  border-radius: var(--avatar-radius);\n}\n\n/* component/button/primary/background family + component/surface/blur —\n   Glass only (2026-08-11, node 2044:26027). Harmless when a real image\n   fills .root (the .image child paints over the background entirely), so\n   applied unconditionally rather than only for the initials fallback. */\n[data-skrewww-surface=\"glass\"] .root {\n  background: var(--component-brand-fill-glass);\n  backdrop-filter: var(--glass-backdrop-filter-lg);\n}\n\n@supports not (backdrop-filter: blur(1px)) {\n  [data-skrewww-surface=\"glass\"] .root {\n    background: var(--component-button-primary-fill);\n  }\n}\n",
      "type": "registry:ui",
      "target": "~/components/ui/avatar.module.css"
    },
    {
      "path": "lib/cn.ts",
      "content": "export function cn(...classes: Array<string | false | null | undefined>): string {\n  return classes.filter(Boolean).join(\" \");\n}\n",
      "type": "registry:lib",
      "target": "~/lib/cn.ts"
    }
  ]
}
