Rost

← All components

component

Avatar

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

In code Contract: review Guidance: proposed Contract on GitHub Figma 733:140 As markdown
Small
Medium
Large

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.

    Use TestimonialPicture

  • Status

    Saying if someone is online or late. Put a Badge beside it, not a colour on it.

    Use Badge

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.

Props

PropTypeValuesDefault
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-radius 10000px spacing/radius/full
  • background #3a3a3a avatar/background

displayinline-flex · align-itemscenter · justify-contentcenter · positionrelative · flex-shrink0 · overflowhidden · vertical-alignmiddle

initials

  • font-family 'General Sans Variable' font-family/base
  • color #ededed avatar/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

PropertySmallMediumLarge
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.

In code Contract: review Guidance: proposed Contract on GitHub Figma 744:48 As markdown
Default

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

PropTypeValuesDefault
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-left 8px spacing/gap/small

displayinline-flex · align-itemscenter

avatar

  • margin-left calc(-1 * var(--spacing-gap-small)) on purpose: Composed from a token: the overlap.
  • box-shadow 0 0 0 var(--spacing-outline-medium) var(--avatar-group-ring) on purpose: Composed from tokens: a 2px ring in avatar-group/ring.

more

  • margin-left calc(-1 * var(--spacing-gap-small)) on purpose: Composed from a token: the overlap.
  • width 40px spacing/size/medium
  • height 40px spacing/size/medium
  • border-radius 10000px spacing/radius/full
  • background #3a3a3a avatar/background
  • box-shadow 0 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-weight 500 typography/paragraph/font-weight/medium
  • font-size 14px typography/paragraph/font-size
  • line-height 20px typography/paragraph/line-height
  • letter-spacing 0px typography/paragraph/letter-spacing
  • color #ededed avatar/initials

positionrelative · displayinline-flex · align-itemscenter · justify-contentcenter