import { cn } from '../../tools/cn'; import { Element } from '../../primitives/element'; import { GridBox } from '../grid-box'; import { Icon } from '../icon'; import { Typography } from '../typography'; import { AVATAR_INITIAL_VARIANT, AVATAR_MARK_PX, AVATAR_PX } from './constants'; import type { AvatarProps } from './types'; import { avatarVariants } from './variants'; /** * A circular creator or user picture. The placeholder sits under the image, so it shows while * the image loads and when it fails, without client code. */ export function Avatar({ name, src, size = 'md', verified = false, muted = false, verifiedLabel, label, className, ...props }: AvatarProps) { const px = AVATAR_PX[size]; return ( {Array.from(name)[0] ?? '?'} {src && ( // A broken image with an empty alt draws nothing, so the letter shows through. )} {verified && ( )} ); }