Avatar
A person in a circle: their initials on a neutral ground, or their picture.
tsx
import { Avatar } from '@adecore/ui';tsx
import { Avatar } from '@adecore/ui';
export default function AvatarDemo() {
return (
<div className="flex flex-col gap-5">
<div className="flex items-center gap-3">
<Avatar name="Sanne de Vries" size="lg" />
<Avatar name="Sanne de Vries" />
<Avatar name="Sanne de Vries" size="sm" />
<Avatar name="mama" />
</div>
<div className="flex items-center gap-2.5">
<Avatar name="Jan Dekker" aria-hidden />
<span className="flex flex-col">
<span className="text-sm font-semibold">Jan Dekker</span>
<span className="text-xs text-text-muted">to me · 09:41</span>
</span>
</div>
</div>
);
}The initials are the first letters of the first two words that start with a capital, so "Sanne de Vries" gives SV. A name without a capital gives its first letter. With src the picture covers the initials once it has loaded; while it loads, or when it fails, the initials stay.
An avatar reads as the name. Beside the name it repeats, such as in the header of a message, pass aria-hidden.
Props
| Prop | Type | Default | |
|---|---|---|---|
name | string | Required. | |
src | string | A picture of the person. | |
size | 'sm' | 'md' | 'lg' | 'md' | 24, 36 and 48 pixels. |
It takes className, ref and the props of a <span>. AvatarProps is an exported type.