Avatar
Profile image, initials, link, or menu trigger.
Status: stable. Group: display. Markdown version: /design-system/components/avatar.md
When to use
Avatar renders a person or entity mark: the image when imageUrl resolves, otherwise initials derived from name. It scales through the size tokens and can act as a link (clickable + destinationUrl) or as a menu trigger (menuItems + menuLabel) with an in-place dropdown. Always pass name; it feeds both the initials fallback and the accessible naming.
When not to use
- Do not render two interactive children inside Avatar (link plus menu); the contract is exactly one interaction mode per instance.
- Do not nest an Avatar inside a Button. Pick one; Avatar already owns the click affordance when clickable, and Button owns it when not.
- Do not use variant="initials" to hide a broken image pipeline; fix the source, the fallback is for genuinely imageless users.
Look-alikes
- Button: Do not nest an Avatar inside a Button. Pick one; Avatar already owns the click affordance when clickable, and Button owns it when not.
Props
| Prop | Type | Default | Description | Required |
|---|---|---|---|---|
name | string | none | No description in the contract. | No |
imageUrl | string | { default: string } | StaticImageData | none | No description in the contract. | No |
clickable | boolean | none | No description in the contract. | No |
destinationUrl | string | none | No description in the contract. | No |
size | AvatarSize | md | Avatar size: token sizes sm/md/lg/xl (2/2.5/3/4rem) are canonical; any CSS length is accepted as an escape hatch. Default md. | No |
srcSet | string | none | No description in the contract. | No |
sizes | string | none | No description in the contract. | No |
loading | "lazy" | "eager" | lazy | No description in the contract. | No |
decoding | "auto" | "sync" | "async" | async | No description in the contract. | No |
menuItems | AvatarMenuItem[] | none | When provided, renders an in-place dropdown menu triggered by the avatar. | No |
menuLabel | string | none | Accessible label announced for the avatar menu trigger. | No |
variant | "image" | "initials" | image | Controls whether the avatar prefers an image or initials. | No |
alt | string | none | Overrides the image alt text (defaults to name). Pass "" when the name is already printed beside the avatar, so it is not read twice. | No |
Variants
- Available variants:
image,initials(defaultimage). - Available sizes:
sm,md,lg,xl,2rem,2.5rem,3rem,4rem,5rem,6rem,7rem,8rem(defaultmd). - Allowed
loadingvalues:lazy,eager(defaultlazy). - Allowed
decodingvalues:auto,sync,async(defaultasync).
Invalid combinations
The contract records no invalid combinations.
Keyboard
The contract records no keyboard interaction.
Rules
Every item under When not to use is a MUST NOT. MUST and SHOULD follow RFC 2119.
| Level | Rule | How it is checked |
|---|---|---|
| MUST | ARIA: Menu trigger needs accessible name. | Not yet verified: no evidence record. WCAG 4.1.2. |
| MUST | ARIA: Image alt from name. | Not yet verified: no evidence record. WCAG 4.1.2. |
| MUST | Required stories produce no axe violations at the configured severity. | Automated by npm run test:stories:matrix:ci. WCAG 2.5.8. |
| MUST | The accessibility tree (role, name, state) matches the committed snapshot for every required story. | Automated by npm run test:stories:matrix:ci. WCAG 1.3.1, 4.1.2. |
| MUST | The component remains legible and operable under a real browser forced-colors: active pass. | Automated by npm run test:stories:hc. |
| MUST | A human completed an end-to-end accessibility review of this component. | Manual review, last on 2026-11-04. |
| SHOULD | Always provide name, even with an image; it is the initials fallback and the accessible name. | Not stated in the contract. |
| SHOULD | Provide srcSet/sizes for photographic avatars so dense grids do not ship desktop images to mobile. | Not stated in the contract. |
| SHOULD | Use menuLabel to say what the menu does ("Account menu"), not who the person is. | Not stated in the contract. |
| SHOULD | Keep loading lazy (default-friendly) in long lists; eager only above the fold. | Not stated in the contract. |
| SHOULD NOT | Do not wrap Avatar in another link/button when clickable or menuItems already make it interactive; nested controls break AT. | Not stated in the contract. |
Install and import
- Install:
npm install @digitaltableteur/react(version 0.9.1, restricted access on npm). - Import:
import { Avatar } from "@digitaltableteur/react"; - Entry point:
@digitaltableteur/react/identityexports it too. - Styles: import
@digitaltableteur/react/style.cssonce at the app boundary. - Also available as the custom element
<dt-avatar>; see the custom elements manifest.
Links
- Machine-readable contract (Design System Contract 1.0)
- Markdown version of this page
- Component index as JSON
- All components
- Source: The implementation lives in a private repository. This page, its Markdown twin and the contract are generated from it at build time and are the public source of truth.