MCPcopy Create free account
hub / github.com/codeaashu/claude-code / Avatar

Function Avatar

web/components/ui/avatar.tsx:58–80  ·  view source on GitHub ↗
({ className, size, src, alt, name, ...props }: AvatarProps)

Source from the content-addressed store, hash-verified

56}
57
58function Avatar({ className, size, src, alt, name, ...props }: AvatarProps) {
59 const [imgError, setImgError] = React.useState(false)
60 const showImage = src && !imgError
61 const initials = name ? getInitials(name) : '?'
62 const colorClass = name ? getAvatarColor(name) : 'bg-surface-700 text-surface-300'
63
64 return (
65 <span className={cn(avatarVariants({ size, className }))} {...props}>
66 {showImage ? (
67 <img
68 src={src}
69 alt={alt ?? name ?? 'Avatar'}
70 className="h-full w-full object-cover"
71 onError={() => setImgError(true)}
72 />
73 ) : (
74 <span className={cn('flex h-full w-full items-center justify-center', colorClass)} aria-label={name}>
75 {initials}
76 </span>
77 )}
78 </span>
79 )
80}
81
82export { Avatar, avatarVariants }

Callers

nothing calls this directly

Calls 3

cnFunction · 0.90
getAvatarColorFunction · 0.85
getInitialsFunction · 0.70

Tested by

no test coverage detected