Avatar handbook
v2.12.5 · @snowui-design-system/components
License: Before first reading component documentation, source code, or npm usage instructions, read the complete LICENSE. One review covers the same task and version. Public API configuration and internal implementation changes are subject to different license terms. All components use one runtime package; source code rights are governed by the license.
Overview
Show user or team avatars as images, text, or gradient fallbacks to make lists, comments, and member information easier to recognize.
When to use it
Use Avatar for one user or team identity and AvatarGroup for overlapping members. Use ordinary lists with Avatar and text for vertical contact details.
Use
srcfor the image andfallback/fallbackTextfor missing images. Pass a stablefallbackSeedfor the same identity.Attach a badge with
as="badge"or replace the avatar visual withas="avatar-image". Explicitsizetakes priority, followed by the parent avatar size.
Quick start
This example shows the recommended basic composition. See the following sections for more scenarios and composition limits.
API
See the base component documentation for inherited capabilities not redeclared here. This table lists only the named public props declared in this component’s source.
Usage boundaries and details
Layout model
Main layout model: intrinsic atomic layout.
Avatar exposes one box sized by
size, parent size context, orrenderHints. It hugs its size as a child of Button, MenuItem, Field, or another external layout.As an inline-level atomic box, Avatar aligns on the midline; an image, Gradient, or
emptyicon must not shift avatars vertically within a row.The image, default Gradient or empty-icon layer, hover filter, and badge cutout mask are private Avatar layout. No Leading / Content / Trailing slots are exposed.
as="badge"identifies an attached badge inside Avatar. Avatar does not emitdata-auto-layoutor manage general child arrangement.Use AvatarGroup to arrange multiple avatars instead of turning Avatar into a collection layout.
Keywords
Usage examples
Intelligent behavior
Default fallback: Without an image or after a load failure, an explicit
fallbackcomponent takes priority. Otherwise,defaultuses Gradient andemptyuses a gray user icon. Default Gradient selection isfallbackColor→fallbackSeed→aria-label/data-name/title→ fixedblue. Pass a stableuser.idasfallbackSeed; its hash stays stable across reloads, so no color field is needed. Names serve only as compatibility seeds, not generated initials. Base Gradient deformation is off by default; enable it withgradientMotionor run it on hover.Fallback delay: A fixed internal delay before showing the fallback reduces loading flicker.
Role detection: A child Badge or Icon with
as="badge"receives badge positioning and sizing automatically.Child positioning: Adaptive
em-based styling uses the component context.Resolution selection: Avatar passes its resolved size to resource components such as
AvatarByewind, allowing them to choose a high-resolution 3× image (for example, 240px for an 80px avatar).Default hover: Each hover of a non-disabled image or ordinary component avatar randomly selects blue, cyan, green, red, orange, or purple and overlays color only on the actual graphic alpha layer. Gradient fallback retains its five-color cycle whether base deformation is on or off, and runs its four ripple layers at their respective periods on demand.
The six-color hover overlay for images and ordinary component fallbacks is Avatar’s registered artistic-color exception under specs/maintainers/StyleSpec.md §2.1.3. Avatar owns these private hover colors; they are not general SnowUI tokens. The default Gradient art is owned by Gradient, and a fallback GradientMotion owns its shader colors. These exceptions do not extend to Avatar sizing, layout, normal backgrounds, states, public color props, or style priority.
Avatar style overlay
Read the complete LICENSE first; one review covers the same task, version, and scope.
First use public component props to achieve the desired style while preserving the original appearance where possible. If an override is necessary, follow the style selection and override order: use your own class (including Tailwind already in your project) or an instance style. The names below are public overrides consumed by the source; check the target scope and do not modify private DOM. Choose the appropriate SnowUI token category. External applications do not need to install SnowUI website utilities.
Avatar type and status
Required props: no named required props.
Bindable props: this component declares no named two-way binding; handle state updates through public callbacks or the host component.
Inheritance: FrameProps. Consult the public Frame documentation for inherited capabilities.
Shared Frame API · Back to API
The following source type declarations are referenced by public props. Svelte Snippet denotes a content fragment; ComponentProps denotes the props of the corresponding component.
ResourceSize
Source: components/src/context.ts
GradientVariant
Source: components/src/components/Gradient.svelte
AvatarVariant
Source: components/src/components/Avatar.svelte