# Avatar

> A person or a client as a small circle. Their photo, or their initials on grey when there's no photo.

| | |
|---|---|
| Kind | component |
| Contract | `review` · [avatar.contract.yaml](https://github.com/Runceanu/rost/blob/master/contracts/avatar.contract.yaml) |
| Guidance | `proposed` |
| Source | [Figma 733:140](https://www.figma.com/design/1Zy0wiWKXQAvsfDBX3KR0d/UI-Kit-v01?node-id=733-140) · read 2026-11-16 · frozen 2026-11-16 |
| Implemented in | nowhere yet |

## Install

It lands in `src/rost/avatar/`, with what it needs and its contract:

```sh
npx github:Runceanu/rost add avatar
```

Then import `src/rost/fonts.css` and `src/rost/tokens.css` once, at the root of the app. More on this in [Install](https://rost.build/docs/install.md).

## Props

| Prop | Type | Values | Default |
|---|---|---|---|
| `name` | string |  |  |
| `src` | string |  |  |
| `size` | enum | `small` `medium` `large` | `medium` |
| `decorative` | boolean |  | `false` |

## Anatomy

- `root`: A `<span>`. With a photo it's the image's frame; without one it's `role="img"` with the name as its label, so the initials aren't read out letter by letter.
- `initials`: Medium weight, in the main text colour. Hidden from screen readers, since the root says the whole name.
- `image`: The photo, cropped to the circle.

## When to use

- **Who did it.** Next to a name in a list, a comment or an activity line, so people find each other at a glance.
- **A client.** A client's logo or initials in a table row.

## When not to use

- **A testimonial.** The quote's picture. That's **TestimonialPicture**, which has its own frame.
- **Status.** Saying if someone is online or late. Put a **Badge** beside it, not a colour on it.

## Behaviour

A photo when there is one, initials on grey when there isn't. The grey is the same for everyone. I didn't give each person a colour of their own: it reads as meaning something when it doesn't.

## Accessibility

- **Element**: With a photo, an `<img>` with the name as `alt`. Without, a `<span role="img">` labelled with the name.
- **Name**: The person's or the client's name. If the name is written right beside it, pass `decorative` so it isn't said twice.
- **Colour**: The initials are 9:1 on the grey in dark.

## Content

Initials come from the name, up to two letters. Don't pass them yourself.

## Tokens

Every token this component uses, across all its variants.

| Token | Resolves to |
|---|---|
| `avatar/background` | `#3a3a3a` |
| `avatar/initials` | `#ededed` |
| `font-family/base` | `'General Sans Variable'` |
| `spacing/radius/full` | `10000px` |
| `spacing/size/large` | `56px` |
| `spacing/size/medium` | `40px` |
| `spacing/size/small-medium` | `32px` |
| `typography/body/font-size` | `16px` |
| `typography/body/font-weight/medium` | `500` |
| `typography/body/letter-spacing` | `0px` |
| `typography/body/line-height` | `22px` |
| `typography/label/font-size` | `12px` |
| `typography/label/font-weight/medium` | `500` |
| `typography/label/letter-spacing` | `0px` |
| `typography/label/line-height` | `14px` |
| `typography/paragraph/font-size` | `14px` |
| `typography/paragraph/font-weight/medium` | `500` |
| `typography/paragraph/letter-spacing` | `0px` |
| `typography/paragraph/line-height` | `20px` |

See it live, with every value of every variant: [rost.build/components/avatar/](https://rost.build/components/avatar/)
