import * as React from 'react' import { cn } from '@/lib/utils' interface AvatarProps extends React.HTMLAttributes { src?: string alt?: string fallback?: string size?: 'sm' | 'md' | 'lg' } const sizeClasses = { sm: 'h-8 w-8 text-xs', md: 'h-10 w-10 text-sm', lg: 'h-12 w-12 text-base', } export function Avatar({ src, alt, fallback, size = 'md', className, ...props }: AvatarProps) { const [error, setError] = React.useState(false) return (
{src && !error ? ( {alt} setError(true)} /> ) : ( {fallback || (alt ? alt.charAt(0).toUpperCase() : '?')} )}
) }