0.1.0-rc.2

Avatar

Avatars identify people or entities with a photo, initials, or generic fallback. Size variants keep them proportional in lists, bylines, and toolbars.

Try it

Usage

Set src and alt when a photo is available. Use fallback for initials when the image fails to load or is not provided.

import { RuiAvatar } from '@ecopages/radiant-ui/avatar';
 
<RuiAvatar src="/avatars/jane.jpg" alt="Jane Cooper" fallback="JC" size="md" />

Meaningful fallback text

Limit fallback to one or two characters derived from the person's name. Avoid arbitrary symbols that do not identify the subject.

Pick size for context

Use sm in dense tables and comment threads, md in bylines and menus, and lg in profile headers.

Theming

Avatar chrome maps to semantic surface roles, never Tailwind palette steps:

PartCSS roles
Rootsurface-container fill, on-surface fallback text, rounded-pill
Imageobject-cover fill
Sizessize-8 (sm) · size-10 (md) · size-12 (lg)

Override at the theme layer, not in component CSS.

Accessibility

  • Always provide alt text when src is set so the image is described to screen readers.
  • When showing only initials, ensure surrounding text names the person; the avatar itself may be decorative.
  • Do not use avatar color as the sole indicator of user role or status.

API

RuiAvatar is a presentational JSX view, no custom element. Pass src for an image, or fallback / alt for initials.

Props

PropTypeDefaultDescription
srcstringImage URL. When omitted, initials from alt / fallback are shown.
altstring''Accessible name for the image; also derives initials.
fallbackstringExplicit fallback initials / text when there is no image.
sizesm · md · lgmdAvatar size.

CSS classes

Public BEM classes (documented via @cssclass):

ClassDescription
.rui-avatar · --sm · --md · --lgRoot + size variants.
.rui-avatar__image<img> fill.
.rui-avatar__fallbackInitials / text fallback.

Theme roles

PartCSS variables consumed
Fallback--surface-container, --on-surface, --radius-pill