Avatar
vig-avatar
import { Avatar } from '@vigdx/ui/avatar';Image, initials and icon
src with an alt ; without an image the avatar shows the initials of name (first and last word), and with neither it shows the user icon.
Sizes
size runs from xs to xl and is relative to the font size, so an avatar also scales with the text around it.
Shapes and variants
shape="square" suits organizations and projects; its corners follow --radius-avatar . variant tints the initials or icon fallback; icon swaps the fallback glyph.
Image fallback
src fails to load the avatar falls back to the initials, then to the icon. A new src retries the image.
namename → iconGroups and profiles
alt so the name is not read twice.
- and 4 more members
Styling hooks
Internal elements carry a stable data-part and the component's data-scope; both are public API, so removing one is a breaking change. Select a part by both, e.g. [data-scope="avatar"][data-part="image"] { … }: the pair stays within this component when kit components nest, and also reaches parts in overlay panels, which render outside the host. State is exposed through aria-* and, where listed, a data-state; literal values are checked by the API gate, values computed from the component's state follow its documented types. Other data-* attributes listed below (such as data-opening while an overlay animates) are API too. See Customizing.
Scope: [data-scope="avatar"]
| Part | Element | data-state |
|---|---|---|
image | <img> . | — |
initials | — | |
icon | — |
Accessibility
- With an image,
altis the accessible name: pass the person's name, or""when the name is already shown next to the avatar. In dev mode the avatar warns whensrchas noalt. - The initials and icon fallbacks are exposed as
role="img"labelled with the fullname(oralt), never with the bare initials. - An avatar with neither image nor name is decorative and hidden from assistive technology.
- Avatars are not interactive. To make one a link or menu trigger, wrap it in an
<a>or<button>with its own accessible name.
API
Avatar
vig-avatarImage of a person or entity, falling back to initials from name and then
to an icon when the image is missing or fails to load.
| Name | Type | Default | Description |
|---|---|---|---|
alt | string | undefined | undefined | Image alternative text — required with |
icon | string | 'user' | Registered icon shown when there is neither an image nor a name. |
name | string | undefined | undefined | Full name: initials fallback and accessible name when no image shows. |
shape | AvatarShape | 'circle' | — |
size | AvatarSize | 'md' | — |
src | string | undefined | undefined | Image URL; when missing or broken the avatar falls back to initials. |
variant | AvatarVariant | 'secondary' | Tone of the initials/icon fallback background. |