Skip to content
Kimenpre-v1
Color scheme

Component

ki-avatar

A static identity visual that shows a person or entity at a glance through a fallback chain: portrait (src), then initials, then a built-in generic figure.

<ki-avatar initials="MG" label="Mars Gotta"></ki-avatar>
<ki-avatar label="Unknown collaborator"></ki-avatar>
<ki-avatar size="xxs" initials="MG" label="Mars Gotta"></ki-avatar>
<ki-avatar size="xs" initials="MG" label="Mars Gotta"></ki-avatar>
<ki-avatar size="sm" initials="MG" label="Mars Gotta"></ki-avatar>
<ki-avatar size="md" initials="MG" label="Mars Gotta"></ki-avatar>
<ki-avatar size="lg" initials="MG" label="Mars Gotta"></ki-avatar>
<ki-avatar size="xl" initials="MG" label="Mars Gotta"></ki-avatar>

A failing or absent src falls back to initials; absent initials fall back to the generic figure. The identity never disappears:

<ki-avatar src="/missing-portrait.png" initials="MG" label="Mars Gotta"></ki-avatar>

Compose several avatars into ki-avatar-group for a compact “who is involved” stack with overflow.

When to use: a compact identity visual for a person or entity — a comment author, a contact list item, a project member. Set label whenever the avatar is the only carrier of the identity (no adjacent visible name); compose several into ki-avatar-group for a compact "who is involved" stack with overflow.

When not to use: as a clickable control (compose the avatar inside an interactive host such as ki-button), for logos or arbitrary illustrations (plain img), for presence/verification adornments overlaid on the corner (a future overlay concern shared with the nav badge), or unlabeled when no adjacent text names the identity.

Properties & attributes

AttributePropertyTypeDefaultDescription
initialsinitialsstring | undefinedInitials rendered verbatim as the second fallback step — never derived from the label, never truncated (FR-003). Catalog guidance: one to two characters. With a label present the initials are presentational; assistive technology receives the label alone.
labellabelstring | undefinedAccessible name for the identity ("Ana García"). With a label the avatar is exposed as a named non-interactive image (role img) in every content mode — the portrait never carries a second alternative text of its own. Without a label the avatar is decorative and contributes nothing to the accessibility tree; the identity must then live in adjacent visible text (FR-002).
sizesize"lg" | "md" | "sm" | "xl" | "xs" | "xxs"'md'Size step over the shared scale; per-size metrics (box, initials font, figure glyph) are per-theme component tokens, never hardcoded (FR-004). An unrecognized value matches no style selector, so the avatar keeps the default medium metrics (fallback by CSS construction, FR-007).
srcsrcstring | undefinedPortrait URL, the first step of the fallback chain. When it fails to load — initially or at runtime — the avatar silently falls back to the initials (or the generic figure) with no error, no layout change and no event (FR-001). Loading policy follows the platform image defaults.

CSS parts

PartDescription
avatarThe avatar box: size, shape, surface, border and typography.
iconThe built-in generic person figure of the last fallback step.
imageThe portrait image when src is set and loads.
initialsThe verbatim initials text of the second fallback step.

CSS custom properties

The public styling contract of ki-avatar: reassign these tokens at :root or on a subtree — never override internals.

TokenDescription
--ki-avatar-bgcolor used by the avatar component for the initials/figure surface: Surface/primary_med_em, the exact variable behind the Type=text gradient start and the Type=icon solid fill. The Figma text gradient (primary_med_em -> primary_low_em_alpha 20%) is deliberately flattened to its solid start color — the token pipeline models no gradients and the spec defines one family-level bg (declared deviation, specs/019-ki-avatar/design-extraction.md decision 2, pending founder ratification).
--ki-avatar-border-colorcolor used by the avatar component for the surface border: Outline/base_em (Black/3 light, White/3 dark), the exact variable on Type=text variants.
--ki-avatar-border-widthdimension used by the avatar component for the surface border (MarsUI 1px hairline on Type=text; applied to the token surface behind initials and figure, dropped under a loaded portrait — design-extraction decision 4).
--ki-avatar-fgcolor used by the avatar component for the initials text and the generic-figure glyph (via currentColor): Text/primary_on_primary, the exact variable on every Type=text variant.
--ki-avatar-font-familyfont family used by the avatar component for initials (MarsUI Typeface/family/body: Inter).
--ki-avatar-font-weightfont weight used by the avatar component for initials (MarsUI Typeface/weight/body/medium: 600).
--ki-avatar-lg-font-sizedimension used by the avatar component for lg initials (MarsUI UI/Body 2: 15px).
--ki-avatar-lg-icon-sizedimension used by the avatar component for the lg generic-figure glyph (MarsUI Icon/User 24px, Space/7xl).
--ki-avatar-lg-sizedimension used by the avatar component for the lg box (48px circle, Figma Space/14xl).
--ki-avatar-md-font-sizedimension used by the avatar component for md initials (MarsUI UI/Para: body_1 13px).
--ki-avatar-md-icon-sizedimension used by the avatar component for the md generic-figure glyph (MarsUI Icon/User 20px, Space/5xl).
--ki-avatar-md-sizedimension used by the avatar component for the md box (40px circle, Figma Space/12xl, node 10011:947).
--ki-avatar-radiusdimension used by the avatar component for the shape: Radius/radius_round bound to every avatar variant — the circle is a radius token, never an attribute (002 shape precedent, FR-005).
--ki-avatar-sm-font-sizedimension used by the avatar component for sm initials (MarsUI UI/Caption 2: 12px).
--ki-avatar-sm-icon-sizedimension used by the avatar component for the sm generic-figure glyph (MarsUI Icon/User 18px, Space/4xl).
--ki-avatar-sm-sizedimension used by the avatar component for the sm box (32px circle, Figma Space/10xl).
--ki-avatar-xl-font-sizedimension used by the avatar component for xl initials (MarsUI UI/Title 2: 18px).
--ki-avatar-xl-icon-sizedimension used by the avatar component for the xl generic-figure glyph (MarsUI Icon/User 28px, Space/9xl).
--ki-avatar-xl-sizedimension used by the avatar component for the xl box (56px circle, Figma Space/16xl).
--ki-avatar-xs-font-sizedimension used by the avatar component for xs initials (MarsUI UI/Caption 1: 10px, same step as xxs — verified on Type=text Size=xs 10108:6226).
--ki-avatar-xs-icon-sizedimension used by the avatar component for the xs generic-figure glyph (MarsUI Icon/User 14px, same step as xxs — NOT the icon-button 16px ramp; verified on 10108:6230).
--ki-avatar-xs-sizedimension used by the avatar component for the xs box (24px circle, Figma Space/7xl).
--ki-avatar-xxs-font-sizedimension used by the avatar component for xxs initials (MarsUI UI/Caption 1: 10px).
--ki-avatar-xxs-icon-sizedimension used by the avatar component for the xxs generic-figure glyph (MarsUI Icon/User 14px, Space/2xl).
--ki-avatar-xxs-sizedimension used by the avatar component for the xxs box (20px circle, Figma Space/5xl; specs/019-ki-avatar/design-extraction.md).
--ki-motion-duration-fastFast interaction transition duration.
--ki-motion-easing-outDecelerating interaction transition easing curve.

Set label whenever the avatar is the only carrier of the identity — no adjacent visible name. An unlabeled avatar next to the person’s visible name is fine; an unlabeled avatar alone is not. For a clickable avatar, compose it inside an interactive host such as ki-button; the avatar itself is never a control.

Open ki-avatar in Storybook