Avatar
Accessible identities with responsive images, deterministic fallbacks, shared Badge composition and overflow-aware groups.
GET STARTED
Import
Import only the identity primitives you render from the granular entry point.
Deterministic fallback priority
A valid image wins, followed by explicit or name-derived initials, an icon class, then projected content. A failed image never remains broken.
Sizes, shapes and image fit
Five size presets combine with circle, rounded or square geometry. Image fit remains independently configurable as cover or contain.
Responsive native image pipeline
srcSet, sizes, loading, decoding, fetch priority and referrer policy map directly to the native image. The root exposes data-image-state as loading, loaded, error or fallback.
Image error and retry
The native error event remains observable while the visual switches to fallback. Changing src resets failure state and retries the new image.
Status and notification Badges
Avatar owns identity; the reusable Badge directive owns dots, counts, severity, logical placement and announcement. No Avatar-only badge API is duplicated.
AvatarGroup and localized overflow
max keeps useful identities visible and replaces the remainder with an accessible +N. The source projection is preserved and reacts when children or max change.
Unstyled and typed class slots
Headless mode retains fixed identity structure, error fallback, semantics, group visibility and logical direction while consumer classes own every visual surface.
Beta boundaries
Included
Images, initials, icons, projected fallback, native loading hints, error retry, sizes, shapes, badges, groups, overflow and headless ownership.
Application-owned
Upload, cropping, presence transport, profile fetching, interactive user menus and tooltip behavior remain separate components or application concerns.
ACCESSIBILITY
Identity without ambiguity
Image and fallback semantics follow the same identity contract while decorative content can stay silent.
Image alternatives
alt is passed to the native image. When omitted, name becomes the alternative. Set alt="" explicitly only when surrounding visible text already names the person and the image is decorative.
Fallback semantics
Initials, icon and projected fallback visuals are hidden from assistive technology; the root uses role="img" with the resolved ariaLabel, name or alt. Without any name, the fallback stays decorative.
Group naming and overflow
Providing ariaLabel creates a named role="group". The overflow count substitutes every {count} occurrence in the localized label; keep that placeholder in translations.
Badge announcements
A visual status dot needs neuralBadgeAriaLabel. Counts should announce their meaning, not only the number. Avatar itself never duplicates these semantics.
RTL and logical layout
Group overlap and Badge positions use inline start/end, so document direction changes require no alternate markup. Avatar has no keyboard behavior because identity alone is not interactive.
PUBLIC CONTRACT
Avatar API
NeuralAvatar inputs
| src | string | null | null | Image source; blank values use fallback. |
| srcSet | string | null | null | Native responsive srcset. |
| sizes | string | null | null | Native responsive sizes hint. |
| alt | string | null | name | Native image alternative; empty marks decorative. |
| name | string | null | null | Fallback initials and accessible identity. |
| initials | string | null | derived | Explicit fallback initials. |
| ariaLabel | string | null | name/alt | Fallback accessible name override. |
| iconClass | string | null | null | Optional class-based fallback icon. |
| size | extra-small | small | medium | large | extra-large | 'medium' | Preset dimensions and type scale. |
| shape | circle | rounded | square | 'circle' | Avatar corner treatment. |
| imageFit | cover | contain | 'cover' | Native object-fit token value. |
| loading | eager | lazy | 'lazy' | Native image loading strategy. |
| decoding | sync | async | auto | 'async' | Native decoding hint. |
| fetchPriority | high | low | auto | 'auto' | Native fetch priority hint. |
| referrerPolicy | string | null | null | Native referrer policy. |
| unstyled | boolean | false | Removes NeuralNg visual classes. |
| avatarClass | string | '' | Additive root class. |
| classes | NeuralAvatarClasses | {} | Typed additive visual slots. |
NeuralAvatar outputs
| imageLoaded | Event | Native image load event after state becomes loaded. |
| imageError | Event | Native image error before fallback becomes visible. |
NeuralAvatarGroup inputs
| max | number | null | null | Maximum visible projected avatars. |
| ariaLabel | string | null | null | Names the optional group landmark. |
| overflowLabel | string | '{count} more avatars' | Localized overflow accessible label. |
| unstyled | boolean | false | Removes group visual classes. |
| groupClass | string | '' | Additive group root class. |
| classes | NeuralAvatarGroupClasses | {} | Typed group slots. |
Typed class slots
Avatar
rootimagefallbackinitialsiconcontentAvatarGroup
rootoverflowDESIGN TOKENS
Avatar tokens
Neutral tokens respond to primary, surface and color mode. Glass and Futuristic override the same contract without changing markup.
Avatar
--neural-avatar-current-sizeResolved avatar width and height after applying the selected size preset.
--neural-avatar-colorComponent foreground color.
--neural-avatar-backgroundComponent background surface.
--neural-avatar-borderComponent border shorthand.
--neural-avatar-shadowComponent box shadow.
--neural-avatar-font-familyComponent font family.
--neural-avatar-font-sizeComponent font size.
--neural-avatar-font-weightComponent font weight.
--neural-avatar-extra-small-sizeExtra small width and height.
--neural-avatar-small-sizeSmall width and height.
--neural-avatar-medium-sizeMedium width and height.
--neural-avatar-large-sizeLarge width and height.
--neural-avatar-extra-large-sizeExtra large width and height.
--neural-avatar-extra-small-font-sizeExtra small font size.
--neural-avatar-small-font-sizeSmall font size.
--neural-avatar-medium-font-sizeMedium font size.
--neural-avatar-large-font-sizeLarge font size.
--neural-avatar-extra-large-font-sizeExtra large font size.
--neural-avatar-circle-radiusCircle corner radius.
--neural-avatar-rounded-radiusRounded corner radius.
--neural-avatar-square-radiusSquare corner radius.
--neural-avatar-image-fitImage object-fit behavior.
--neural-avatar-image-positionImage object position.
--neural-avatar-fallback-colorFallback foreground color.
--neural-avatar-fallback-backgroundFallback background surface.
--neural-avatar-icon-sizeIcon width and height.
AvatarGroup
--neural-avatar-group-overlapGroup overlap distance.
--neural-avatar-group-ring-colorGroup ring foreground color.
--neural-avatar-group-avatar-ringGroup avatar outline ring.
--neural-avatar-group-overflow-sizeGroup overflow width and height.
--neural-avatar-group-overflow-colorGroup overflow foreground color.
--neural-avatar-group-overflow-backgroundGroup overflow background surface.
--neural-avatar-group-overflow-borderGroup overflow border shorthand.
--neural-avatar-group-overflow-radiusGroup overflow corner radius.
--neural-avatar-group-overflow-ringGroup overflow outline ring.
--neural-avatar-group-overflow-font-sizeGroup overflow font size.
--neural-avatar-group-overflow-font-weightGroup overflow font weight.