{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "avatar", "type": "registry:ui", "title": "Avatar", "description": "Avatar with image fallback and status indicators.", "dependencies": [], "registryDependencies": [], "files": [ { "path": "registry/starkui/avatar.tsx", "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { cn } from \"@/lib/utils\";\n\nconst sizes = {\n sm: \"h-8 w-8 text-xs\",\n md: \"h-10 w-10 text-sm\",\n lg: \"h-12 w-12 text-base\",\n xl: \"h-16 w-16 text-lg font-semibold\",\n} as const;\n\nconst statusColors = {\n online: \"bg-emerald-500\",\n offline: \"bg-muted-foreground/50\",\n busy: \"bg-amber-500\",\n} as const;\n\nexport interface AvatarProps extends React.HTMLAttributes {\n src?: string;\n alt?: string;\n fallback?: string;\n size?: keyof typeof sizes;\n status?: keyof typeof statusColors;\n}\n\nexport function Avatar({\n src,\n alt = \"\",\n fallback,\n size = \"md\",\n status,\n className,\n ...props\n}: AvatarProps) {\n const [imageError, setImageError] = React.useState(false);\n\n return (\n
\n \n {src && !imageError ? (\n setImageError(true)}\n className=\"h-full w-full object-cover\"\n />\n ) : (\n {fallback ?? (alt.slice(0, 2).toUpperCase() || \"??\")}\n )}\n
\n\n {status && (\n \n )}\n \n );\n}\n", "type": "registry:ui", "target": "components/ui/avatar.tsx" } ] }