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"/>Examples
Section titled “Examples”Primary
Section titled “Primary”Used as the default visual identity style.
Secondary
Section titled “Secondary”Used for lower-emphasis identity contexts.
Tertiary
Section titled “Tertiary”Used in minimal or bordered contexts where subtle contrast is required.
API Reference
Section titled “API Reference”| Prop | Type | Default | Description |
|---|---|---|---|
model | { src?: string; alt?: string } | — | CMS-normalized avatar model. |
src | string | null | — | Image source URL. Overrides model.src if provided. |
alt | string | null | — | Alternative text. Overrides model.alt if provided. |
decorative | boolean | false | If 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. |
fallback | React.ReactNode | — | Custom fallback content when image is missing or fails. |
fallbackIcon | React.ReactNode | Default icon | Convenience override for default SVG fallback icon. |
className | string | — | Additional classes applied to the root element. |
imageClassName | string | — | Additional classes applied to the <img> element. |
fallbackClassName | string | — | Additional classes applied to the fallback container. |
fallbackIconWrapperClassName | string | — | 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.
Accessibility
Section titled “Accessibility”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.
Related Patterns
Section titled “Related Patterns”Testimonial
Teams