Avatar
Avatars represent users or entities with images, initials, or placeholder icons. They support multiple sizes and color themes.
Avatar Playground
Avatar Playground
Preview
Code










Controls
Type:
Image
Initials
Placeholder
Size:
XXL
XL
L
M
S
XS
XXS
XXXS
Avatar Group Playground
Avatar Group Playground
Preview
Code
+4
Controls
Size:
XXXS
XXS
XS
S
M
L
Max Visible:
2
3
4
5
6
Installation
You can add the avatar component to your project manually:
1
Install the following dependencies:
npm
pnpm
yarn
bun
npm install class-variance-authority2
Copy and paste the following code into your project.
Avatar.tsx
AvatarGroup.tsx
Material.tsx
Loading source code...
3
Update the import paths to match your project setup.
Update the import aliases (e.g. @/components, @/utils) in the copied files to match your project's path configuration.
Basic Usage
Avatar
import { Avatar } from '@versaui/ui/components/Avatar';
// Image avatar
<Avatar type="image" person="adam-smith" size="l" />
// Initials avatar
<Avatar type="initials" initials="JD" color="primary" />
// Placeholder avatar
<Avatar type="placeholder" decorative />Avatar Group
import { AvatarGroup } from '@versaui/ui/components/Avatar';
<AvatarGroup
size="m"
max={4}
persons={['adam-smith', 'denver-whitman', 'jacob-wilson', 'xavier-hernandez', 'zakir-khan']}
/>Avatar Types
Avatars can be photographic, based on initials, or a generic placeholder:
// Image — uses a pre-defined person photo
<Avatar type="image" person="adam-smith" size="l" />
// Initials — displays up to two characters
<Avatar type="initials" initials="JD" color="primary" size="l" />
// Placeholder — generic user silhouette
<Avatar type="placeholder" size="l" />Color Variants
Avatars with type="initials" or type="placeholder" support five color themes:
<Avatar type="initials" initials="AB" color="neutral" />
<Avatar type="initials" initials="CD" color="primary" />
<Avatar type="initials" initials="EF" color="secondary" />
<Avatar type="initials" initials="GH" color="tertiary" />
<Avatar type="initials" initials="IJ" color="quaternary" />Overflow Handling
The group automatically calculates overflow based on the max prop:
// Max 3 — fourth avatar becomes a "+1" overflow indicator
<AvatarGroup
max={3}
persons={['adam-smith', 'denver-whitman', 'jacob-wilson', 'xavier-hernandez']}
/>
// Full group — no overflow indicator
<AvatarGroup
max={5}
persons={['adam-smith', 'denver-whitman', 'jacob-wilson']}
/>Accessibility
The Avatar component is fully accessible:
- Decorative avatars: Set
decorativeto hide from screen readers when the avatar is purely visual - Labeled avatars: Provide
aria-labelfor meaningful identification - Groups: AvatarGroup conveys the total count and overflow to assistive technology
Avatar Props
| Prop | Type | Default | Description |
|---|---|---|---|
size | 'xxxs' | 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl' | 'm' | Avatar size. |
type | 'image' | 'initials' | 'placeholder' | 'initials' | Visual type of avatar. |
color | 'neutral' | 'primary' | 'secondary' | 'tertiary' | 'quaternary' | 'neutral' | Color theme for initials/placeholder. |
person | AvatarPerson | 'adam-smith' | Pre-defined person photo (image type). |
initials | string | — | Up to two characters (initials type). |
decorative | boolean | false | Hide from screen readers. |
aria-label | string | — | Accessible label. |
AvatarGroup Props
| Prop | Type | Default | Description |
|---|---|---|---|
size | 'xxxs' | 'xxs' | 'xs' | 's' | 'm' | 'l' | 'm' | Size for all avatars in group. |
persons | AvatarPerson[] | [] | Array of person identifiers. |
max | number | 4 | Maximum visible avatars before overflow. |
aria-label | string | — | Accessible label for the group. |