component
Avatar
A person or a client as a small circle. Their photo, or their initials on grey when there's no photo.
SmallMediumLargeimport { Avatar } from 'rost/components/avatar/Avatar'
<Avatar name="Client One" />
<Avatar name="Client One" src={photo} size="large" /> src/components/avatar/Avatar.tsx
import type { HTMLAttributes } from 'react'
import './avatar.css'
export type AvatarSize = 'small' | 'medium' | 'large'
export interface AvatarProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'children'> {
/** Who it is. The initials come from it, and it's what a screen reader says. */
readonly name: string
/** The photo. Without it, the initials. */
readonly src?: string
readonly size?: AvatarSize
/** The name is written right beside it, so screen readers skip this. */
readonly decorative?: boolean
}
const b = 'rost-avatar'
/** "Client One" -> "CO", "accounting" -> "A". */
export const initialsOf = (name: string) => name.trim().split(/\s+/).slice(0, 2).map((w) => w[0] ?? '').join('').toUpperCase()
/**
* A person or a client as a circle: their photo, or their initials on grey.
* Built from contracts/avatar.contract.yaml.
*/
export function Avatar({ name, src, size = 'medium', decorative = false, className, ...rest }: AvatarProps) {
const cls = [b, `${b}--size-${size}`, className].filter(Boolean).join(' ')
const a11y = decorative ? { 'aria-hidden': true } : src ? {} : { role: 'img', 'aria-label': name }
return (
<span className={cls} {...a11y} {...rest}>
{src
? <img className={`${b}__image`} src={src} alt={decorative ? '' : name} />
: <span className={`${b}__initials`} aria-hidden="true">{initialsOf(name)}</span>}
</span>
)
}
The source for everything on this page: contracts/avatar.contract.yaml (opens in a new tab). The CSS, the docs and the checks in each app are built from it.
# yaml-language-server: $schema=../schema/component-contract.schema.json
schemaVersion: 2
id: avatar
name: Avatar
kind: component
status: review
summary: A person or a client as a small circle. Their photo, or their initials on grey when there's no photo.
category: display
related: [ testimonials-pics, badge ]
source:
tool: figma
fileKey: 1Zy0wiWKXQAvsfDBX3KR0d
nodeId: "733:140"
url: https://www.figma.com/design/1Zy0wiWKXQAvsfDBX3KR0d/UI-Kit-v01?node-id=733-140
extractedAt: "2026-11-16"
extractedBy: hand
frozenAt: "2026-11-16"
props:
name: { type: string, required: true, notes: "Who it is. The initials come from it (the first letter of the first two words), and it's the photo's alt text." }
src: { type: string, notes: "The photo. Without it, the initials." }
size:
type: enum
values: [ small, medium, large ]
default: medium
notes: "`small` (32) in a table row or a list, `medium` (40) beside a name, `large` (56) on its own, the size of a testimonial's picture."
decorative: { type: boolean, default: false, notes: "When the name is written right beside it. Screen readers skip it then, so the name isn't said twice." }
elements:
root:
notes: "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."
styles:
display: { value: inline-flex, assert: false }
align-items: { value: center }
justify-content: { value: center }
position: { value: relative, assert: false }
flex-shrink: { value: "0", assert: false }
overflow: { value: hidden, assert: false }
vertical-align: { value: middle, assert: false }
border-radius: { token: spacing/radius/full, value: 10000px }
background: { token: avatar/background, value: "#3a3a3a" }
initials:
notes: Medium weight, in the main text colour. Hidden from screen readers, since the root says the whole name.
styles:
font-family: { token: font-family/base, value: "'General Sans Variable'" }
color: { token: avatar/initials, value: "#ededed" }
text-transform: { value: uppercase, assert: false }
user-select: { value: none, assert: false }
image:
notes: The photo, cropped to the circle.
styles:
position: { value: absolute, assert: false }
inset: { value: "0", assert: false }
width: { value: 100%, assert: false }
height: { value: 100%, assert: false }
object-fit: { value: cover, assert: false }
variants:
- when: { size: small }
figmaNode: "733:133"
elements:
root:
width: { token: spacing/size/small-medium, value: 32px }
height: { token: spacing/size/small-medium, value: 32px }
initials:
font-size: { token: typography/label/font-size, value: 12px }
line-height: { token: typography/label/line-height, value: 14px }
font-weight: { token: typography/label/font-weight/medium, value: "500" }
letter-spacing: { token: typography/label/letter-spacing, value: 0px }
- when: { size: medium }
figmaNode: "733:135"
elements:
root:
width: { token: spacing/size/medium, value: 40px }
height: { token: spacing/size/medium, value: 40px }
initials:
font-size: { token: typography/paragraph/font-size, value: 14px }
line-height: { token: typography/paragraph/line-height, value: 20px }
font-weight: { token: typography/paragraph/font-weight/medium, value: "500" }
letter-spacing: { token: typography/paragraph/letter-spacing, value: 0px }
- when: { size: large }
figmaNode: "733:137"
elements:
root:
width: { token: spacing/size/large, value: 56px }
height: { token: spacing/size/large, value: 56px }
initials:
font-size: { token: typography/body/font-size, value: 16px }
line-height: { token: typography/body/line-height, value: 22px }
font-weight: { token: typography/body/font-weight/medium, value: "500" }
letter-spacing: { token: typography/body/letter-spacing, value: 0px }
guidance:
status: proposed
use:
- title: Who did it
text: "Next to a name in a list, a comment or an activity line, so people find each other at a glance."
show: size=medium
- title: A client
text: "A client's logo or initials in a table row."
show: size=small
avoid:
- title: A testimonial
text: "The quote's picture. That's **TestimonialPicture**, which has its own frame."
- title: Status
text: "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.
Install
npx github:Runceanu/rost add avatar It lands in src/rost/avatar/, with what it needs and its contract. Install has the rest.
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 asalt. 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
decorativeso 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.
Props
| Prop | Type | Values | Default |
|---|---|---|---|
name | string | | |
src | string | | |
size | enum | small · medium · large | medium |
decorative | boolean | | false |
Values
Straight from the contract. Each value sits next to its token, because six tokens here all come out as #3a3a3a and the colour alone can't tell you which one is right.
Never changes
root
-
border-radius10000pxspacing/radius/full -
background#3a3a3aavatar/background
displayinline-flex · align-itemscenter · justify-contentcenter · positionrelative · flex-shrink0 · overflowhidden · vertical-alignmiddle
initials
-
font-family'General Sans Variable'font-family/base -
color#edededavatar/initials
text-transformuppercase · user-selectnone
image
positionabsolute · inset0 · width100% · height100% · object-fitcover
Changes by variant
3 variants. Each table is what one thing changes with: a column per size, a row per property. Where every row starts with the same token path, it's written once, under the property.
Follows size
| Property | Small | Medium | Large |
|---|---|---|---|
initials.font-sizetypography/… | label/font-size 12px | paragraph/font-size 14px | body/font-size 16px |
initials.font-weighttypography/… | label/font-weight/medium 500 | paragraph/font-weight/medium 500 | body/font-weight/medium 500 |
initials.letter-spacingtypography/… | label/letter-spacing 0px | paragraph/letter-spacing 0px | body/letter-spacing 0px |
initials.line-heighttypography/… | label/line-height 14px | paragraph/line-height 20px | body/line-height 22px |
root.heightspacing/size/… | small-medium 32px | medium 40px | large 56px |
root.widthspacing/size/… | small-medium 32px | medium 40px | large 56px |
Part of Avatar
AvatarGroup
Who is involved, without a list. Medium Avatars overlapping by 8px, each ringed in the page colour, and how many more.
Defaultimport { AvatarGroup } from 'rost/components/avatar-group/AvatarGroup'
<AvatarGroup people={team} max={3} /> src/components/avatar-group/AvatarGroup.tsx
import type { HTMLAttributes } from 'react'
import { Avatar } from '../avatar/Avatar'
import './avatar-group.css'
export interface AvatarGroupProps extends HTMLAttributes<HTMLDivElement> {
/** Who, in order. */
readonly people: readonly { readonly name: string; readonly src?: string }[]
/** How many to show before the rest become +N. */
readonly max?: number
}
const b = 'rost-avatar-group'
/** Who is involved, without a list. Built from contracts/avatar-group.contract.yaml. */
export function AvatarGroup({ people, max = 3, className, ...rest }: AvatarGroupProps) {
const shown = people.slice(0, max)
const more = people.length - shown.length
return (
<div role="group" aria-label={people.map((p) => p.name).join(', ')} className={[b, className].filter(Boolean).join(' ')} {...rest}>
{shown.map((p, i) => <Avatar key={i} className={`${b}__avatar`} name={p.name} src={p.src} decorative />)}
{more > 0 && <span className={`${b}__more`} aria-hidden="true">+{more}</span>}
</div>
)
}
The source for everything on this page: contracts/avatar-group.contract.yaml (opens in a new tab). The CSS, the docs and the checks in each app are built from it.
# yaml-language-server: $schema=../schema/component-contract.schema.json
schemaVersion: 2
id: avatar-group
name: AvatarGroup
kind: component
status: review
partOf: avatar
summary: "Who is involved, without a list. Medium Avatars overlapping by 8px, each ringed in the page colour, and how many more."
category: display
related: [ avatar ]
source:
tool: figma
fileKey: 1Zy0wiWKXQAvsfDBX3KR0d
nodeId: "744:48"
url: https://www.figma.com/design/1Zy0wiWKXQAvsfDBX3KR0d/UI-Kit-v01?node-id=744-48
extractedAt: "2026-11-16"
extractedBy: hand
frozenAt: "2026-11-16"
props:
people: { type: slot, required: true, notes: "The names, and photos if there are any." }
max: { type: number, default: 3, notes: "How many to show before the rest become +N." }
elements:
root:
notes: "A row. It starts 8px in, so the first Avatar sits flush after each one pulls 8px back."
styles:
display: { value: inline-flex, assert: false }
align-items: { value: center }
padding-left: { token: spacing/gap/small, value: 8px }
avatar:
notes: "A medium Avatar, pulled 8px over the one before, with a 2px ring in the page colour to keep them apart."
styles:
margin-left: { value: "calc(-1 * var(--spacing-gap-small))", untokenised: "Composed from a token: the overlap." }
box-shadow: { value: "0 0 0 var(--spacing-outline-medium) var(--avatar-group-ring)", untokenised: "Composed from tokens: a 2px ring in avatar-group/ring." }
more:
notes: "How many more, in a 40px circle like a medium Avatar's."
styles:
position: { value: relative, assert: false, notes: "As an Avatar is, so it overlaps the last one the way each Avatar overlaps the one before." }
display: { value: inline-flex, assert: false }
align-items: { value: center }
justify-content: { value: center }
margin-left: { value: "calc(-1 * var(--spacing-gap-small))", untokenised: "Composed from a token: the overlap." }
width: { token: spacing/size/medium, value: 40px }
height: { token: spacing/size/medium, value: 40px }
border-radius: { token: spacing/radius/full, value: 10000px }
background: { token: avatar/background, value: "#3a3a3a" }
box-shadow: { value: "0 0 0 var(--spacing-outline-medium) var(--avatar-group-ring)", untokenised: "Composed from tokens: a 2px ring in avatar-group/ring." }
font-family: { token: font-family/base, value: "'General Sans Variable'" }
font-weight: { token: typography/paragraph/font-weight/medium, value: "500" }
font-size: { token: typography/paragraph/font-size, value: 14px }
line-height: { token: typography/paragraph/line-height, value: 20px }
letter-spacing: { token: typography/paragraph/letter-spacing, value: 0px }
color: { token: avatar/initials, value: "#ededed" }
guidance:
status: proposed
use:
- title: Who's on it
text: "The people on a project or the clients in a group, where the count matters more than the names."
avoid:
- title: A list of people
text: "When the names matter, write them out, with a small Avatar beside each."
behaviour: "Up to `max` Avatars, overlapping, then +N for the rest."
accessibility:
element: "A `<div role=\"group\">` labelled with all the names, so the hidden ones are read too."
name: "Every name, in the group's label."
colour: "The +N is 9:1 on its grey."
Install
npx github:Runceanu/rost add avatar-group It lands in src/rost/avatar-group/, with what it needs and its contract. Install has the rest.
When to use
Who's on it
The people on a project or the clients in a group, where the count matters more than the names.
When not to use
A list of people
When the names matter, write them out, with a small Avatar beside each.
Behaviour
Up to max Avatars, overlapping, then +N for the rest.
Accessibility
- Element
A
<div role="group">labelled with all the names, so the hidden ones are read too. - Name
Every name, in the group's label.
- Colour
The +N is 9:1 on its grey.
Props
| Prop | Type | Values | Default |
|---|---|---|---|
people | slot | | |
max | number | | 3 |
Values
Straight from the contract. Each value sits next to its token, because six tokens here all come out as #3a3a3a and the colour alone can't tell you which one is right.
Never changes
root
-
padding-left8pxspacing/gap/small
displayinline-flex · align-itemscenter
avatar
-
margin-leftcalc(-1 * var(--spacing-gap-small))on purpose: Composed from a token: the overlap. -
box-shadow0 0 0 var(--spacing-outline-medium) var(--avatar-group-ring)on purpose: Composed from tokens: a 2px ring in avatar-group/ring.
more
-
margin-leftcalc(-1 * var(--spacing-gap-small))on purpose: Composed from a token: the overlap. -
width40pxspacing/size/medium -
height40pxspacing/size/medium -
border-radius10000pxspacing/radius/full -
background#3a3a3aavatar/background -
box-shadow0 0 0 var(--spacing-outline-medium) var(--avatar-group-ring)on purpose: Composed from tokens: a 2px ring in avatar-group/ring. -
font-family'General Sans Variable'font-family/base -
font-weight500typography/paragraph/font-weight/medium -
font-size14pxtypography/paragraph/font-size -
line-height20pxtypography/paragraph/line-height -
letter-spacing0pxtypography/paragraph/letter-spacing -
color#edededavatar/initials
positionrelative · displayinline-flex · align-itemscenter · justify-contentcenter