Avatar
User avatar with image, initials fallback, and status indicator.
Rendering Avatar…
Installation
Copy the source into your project with the CLI. It lands under @/components/ui and is yours to edit.
npx mlola-ui add avatarUsage
import { Avatar, AvatarGroup } from "@/components/ui/avatar";
export default function Example() {
return (
<AvatarGroup max={3}>
<Avatar name="Lena Park" status="online" />
<Avatar name="Kai Tanaka" />
<Avatar name="Rin Sato" />
<Avatar name="Omar Haddad" />
</AvatarGroup>
);
}Styling comes from the engine stylesheet and the nearest theme. Set it once at the root:
<html data-theme="graphite" data-mode="light">HTML
The markup the example above renders, exactly. It needs no script: write it from any language or template.
<div class="ml-avatar-group" role="group" aria-label="Avatar group, 4 people">
<span class="ml-avatar-group-item"><span class="ml-avatar-root" data-size="md"><span class="ml-avatar"><span class="ml-avatar-fallback" role="img" aria-label="Lena Park">LP</span></span><span class="ml-avatar-status" role="status" aria-label="Lena Park is online" data-status="online"></span></span></span>
<span class="ml-avatar-group-item"><span class="ml-avatar-root" data-size="md"><span class="ml-avatar"><span class="ml-avatar-fallback" role="img" aria-label="Kai Tanaka">KT</span></span></span></span>
<span class="ml-avatar-group-item"><span class="ml-avatar-root" data-size="md"><span class="ml-avatar"><span class="ml-avatar-fallback" role="img" aria-label="Rin Sato">RS</span></span></span></span>
<span class="ml-avatar-overflow"><span aria-hidden="true">+1</span><span class="ml-visually-hidden">1 more person</span></span>
</div>Options
| Prop | Values | Default |
|---|---|---|
size | xssmmdlgxl | md |
status | onlineofflineawaybusy | — |
Every prop with a fixed set of values, read from the exported TypeScript types with its doc comment. Open the Code tab above for the rest of the API.
Classes and attributes
A class names each element; data-* and aria-* attributes carry its variant and state. The values listed are the ones the stylesheet draws; the default needs no attribute.
| Class | Attributes |
|---|---|
ml-avatar-root | data-size="lg | sm | xl | xs" |
ml-avatar | — |
ml-avatar-image | — |
ml-avatar-fallback | — |
ml-avatar-status | data-status="away | busy | online" |
ml-avatar-group | — |
ml-avatar-group-item | — |
ml-avatar-overflow | — |
Accessibility and theming
- Semantic elements, accessible names and state relationships are part of the contract.
- Keyboard, pointer and touch paths are operable; focus stays visible in every theme.
- Light and dark modes pass WCAG AA contrast in all 5 canonical themes.
- Reduced motion and forced colors keep meaning and operation.