|
| 1 | +--- |
| 2 | +name: avatar |
| 3 | +platform: react-native (Windows, macOS) |
| 4 | +description: Atomic identity element representing a person, group, or entity. Covers three mutually exclusive display modes (Image, Icon, Initials), eight numeric sizes (16 / 20 / 24 / 28 / 32 / 40 / 56 / 120 px diameter), and non-interactive state handling. |
| 5 | +argument-hint: "[display mode or token question, e.g. 'icon avatar background token' or 'initials accessibility']" |
| 6 | +tokens: tokens.yaml |
| 7 | +accessibility: accessibility.md |
| 8 | +interaction: interaction.md |
| 9 | +usage: usage.md |
| 10 | +--- |
| 11 | + |
| 12 | +## Metadata |
| 13 | + |
| 14 | +| Field | Value | |
| 15 | +| --------- | ------ | |
| 16 | +| Type | atomic | |
| 17 | +| Component | Avatar | |
| 18 | + |
| 19 | +This spec covers the Avatar component for React Native (Windows & macOS). React Native tokens are in `tokens.yaml`, React Native interaction guidance (keyboard, focus, animation) is in `interaction.md`, React Native accessibility guidance (ARIA, WCAG, screen reader) is in `accessibility.md`, and shared usage guidance is in `usage.md` — read the relevant companion file before answering. |
| 20 | + |
| 21 | +Answer design questions directly — lead with rationale, then tokens. Image, Icon, and Initials are mutually exclusive display modes — never show more than one simultaneously. Avatar is non-interactive; the component carries no focus ring, hover, or pressed states. |
| 22 | + |
| 23 | +--- |
| 24 | + |
| 25 | +# Avatar |
| 26 | + |
| 27 | +## Spec |
| 28 | + |
| 29 | +### Anatomy |
| 30 | + |
| 31 | +1. **Container** — circular frame; owns the fixed diameter per size, border radius, and background fill. Avatar has no container stroke — the fill defines the circle across all three content modes. |
| 32 | +2. **Image slot** — a user photo or entity image that covers the **entire** container edge-to-edge (full-bleed). The image spans the full diameter and is clipped to the circular radius — the per-size padding (see `tokens.yaml` `spacing`) applies to the Icon and Initials slots only, **never** to Image; an image inset by padding would render as a square that never reaches the circular clip. Active only in the Image display mode. |
| 33 | +3. **Icon slot** — centered Fluent Iconography instance representing the entity type. Active only in the Icon display mode. |
| 34 | +4. **Initials slot** — centered text node showing 1–2 characters (1 character at size 16). Active only in the Initials display mode. Uses `line-height: 1` override at all sizes for optical centering — see `tokens.yaml` (`typography.initials-line-height-override`) for rationale. |
| 35 | +5. **Activity ring** — a brand outline offset from the avatar container, indicating the person is active or collaborating in a shared space. The offset creates a true transparent gap that reveals the surface beneath. Both offset and stroke width scale with avatar size so the ring stays proportional at every diameter. Controlled by a boolean property. Does not affect layout dimensions (rendered as `outline` + `outline-offset`). |
| 36 | + |
| 37 | +| Slot | Required | Default | |
| 38 | +| ------------- | --------------------------------- | ----------- | |
| 39 | +| Image | No — active in Image mode only | — | |
| 40 | +| Icon | No — active in Icon mode only | Person icon | |
| 41 | +| Initials | No — active in Initials mode only | "AB" | |
| 42 | +| Activity ring | No | Hidden | |
| 43 | + |
| 44 | +--- |
| 45 | + |
| 46 | +### Variants |
| 47 | + |
| 48 | +Variant properties are ordered in the design tool: **Content → Size → State**. |
| 49 | + |
| 50 | +#### Content |
| 51 | + |
| 52 | +| Value | Description | When to Use | |
| 53 | +| ------------ | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | |
| 54 | +| **Image** | Photo or entity image fills the container | When a real user photo or entity brand image is available | |
| 55 | +| **Icon** | Fluent Iconography icon centered in a filled container | When no photo is available and entity type can be represented by an icon | |
| 56 | +| **Initials** | 1–2 character text centered in a filled container (1 character at size 16) | When no photo is available and entity type is best represented by initials | |
| 57 | + |
| 58 | +**Why three modes share the same component:** Image, Icon, and Initials all resolve to the same circular container with identical sizing, padding, and accessibility surface — they differ only in which inner slot is rendered. A Content variant keeps the three fallback paths consistent so callers can swap between them based on data availability without reflowing layout. |
| 59 | + |
| 60 | +--- |
| 61 | + |
| 62 | +#### Size |
| 63 | + |
| 64 | +Size is a numeric scale — the variant value is the container's pixel diameter. Eight sizes are valid: **16, 20, 24, 28, 32, 40, 56, 120**. The numeric scale lets the component grow new stops without naming churn while still capturing the full set of valid sizes the design system supports. |
| 65 | + |
| 66 | +| Value | Diameter | When to Use | |
| 67 | +| ------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------- | |
| 68 | +| **16** | 16px | Dense surfaces: inline mentions, compact participant lists, chat bubbles. Initials are constrained to a single character at this size. | |
| 69 | +| **20** | 20px | Dense rows where 16 reads too small but 28 reads too heavy: compact toolbars, tight list cells, status strips. | |
| 70 | +| **24** | 24px | Dense rows where 20 reads too small but 28 reads too heavy: compact toolbars, tight list cells, status strips. | |
| 71 | +| **28** | 28px | Compact list rows and inline person chips that need slightly more identity weight than 16 | |
| 72 | +| **32** | 32px | Tight rows where text and avatar share a single line: input chips, condensed participant rosters | |
| 73 | +| **40** | 40px | Default. Comment threads, assignment fields, profile headers | |
| 74 | +| **56** | 56px | High-emphasis identity moments: profile cards, people pickers, detail views | |
| 75 | +| **120** | 120px | Hero moments: large profile views, about pages, onboarding flows | |
| 76 | + |
| 77 | +**Why sizes share the same content treatment:** Size changes only the container diameter, icon size, and typography scale — not semantic meaning. **Why a numeric scale rather than named buckets:** Once a system carries more than ~4 sizes, names like Small / Medium / Large / XL run out fast. A pixel-named scale keeps the contract honest while still constraining consumers to the documented set. |
| 78 | + |
| 79 | +--- |
| 80 | + |
| 81 | +#### State |
| 82 | + |
| 83 | +| Value | Description | |
| 84 | +| -------- | --------------- | |
| 85 | +| **Rest** | Default display | |
| 86 | + |
| 87 | +Avatar is non-interactive — no Hover, Pressed, Focus, or Disabled states apply. |
0 commit comments