Skip to content

Avatar

The Avatar component is a reusable identity primitive that renders a user’s profile image in a consistent circular format. It supports CMS-normalized models and direct src/alt usage, enforces accessible image handling, and gracefully falls back to a default icon when the image is missing or fails to load. Designed to be layout-agnostic and portable across frameworks, it ensures predictable and accessible identity representation across an application.

import { Avatar } from "@/rokkit200-ui/components/avatar/avatar";
<Avatar
size="lg"
variant="primary"
src="https://i.pravatar.cc/150?img=3"
alt="Jane Doe"
/>

Used as the default visual identity style.

Used for lower-emphasis identity contexts.

Used in minimal or bordered contexts where subtle contrast is required.

PropTypeDefaultDescription
model{ src?: string; alt?: string }—CMS-normalized avatar model.
srcstring | null—Image source URL. Overrides model.src if provided.
altstring | null—Alternative text. Overrides model.alt if provided.
decorativebooleanfalseIf true, forces alt="" and treats the avatar as decorative.
size"xs" | "sm" | "md" | "lg" | "xl" | number | string"lg"Preset or custom size for width and height.
variant"primary" | "secondary" | "tertiary""primary"Visual color variant.
fallbackReact.ReactNode—Custom fallback content when image is missing or fails.
fallbackIconReact.ReactNodeDefault iconConvenience override for default SVG fallback icon.
classNamestring—Additional classes applied to the root element.
imageClassNamestring—Additional classes applied to the <img> element.
fallbackClassNamestring—Additional classes applied to the fallback container.
fallbackIconWrapperClassNamestring—Additional classes applied to the fallback icon wrapper <div>.

Images are always rendered with loading=“lazy” and decoding=“async” enforced.

SVG URLs are treated as standard image sources.

Direct props (src, alt) take precedence over model values.

Always renders a semantic <img> element when src is present.

If decorative={true}, the avatar renders with alt="".

If not decorative and alt is missing, a development warning is emitted.

Fallback content is marked aria-hidden when decorative.

The component is designed to meet WCAG 2.1 AA requirements when used as intended.

Testimonial

Teams