Avatar is how Seed Exact shows who. It draws a person's profile picture as a circle, and when there is no picture it draws a green disc with the first letter of their name in white. It is a named component, defined in ui.contract L6-L21, and it is the most reused component in the app.
Props
Prop | Type | Effect |
|---|---|---|
| string | The accessible label of the avatar, the source of the initial, and the seed of the disc colour |
| string | The picture. Empty means draw the initial disc |
| number | Width and height in points |
Anatomy
With a picture (url is not empty): one image, size by size, border-radius="50%", object-fit="cover", labelled with the name.
Without a picture: a row of the same size and radius, centred content, filled with hsl(avatarHue(name), 54%, 32%). Inside it one text: the first character of the name in upper case, or "?" when the name is empty, in ink.on-brand (white in both schemes) at weight 600. The letter is hidden from assistive technology (aria-hidden), because the disc already carries the name.
The hue
fn avatarHue(name: string): number = 127 + sum(name.toLowerCase().split("").map((c, i) => ("abcdefghijklmnopqrstuvwxyz0123456789".indexOf(c) + 2) * (i + 7))) % 49Each character contributes its position in the alphabet plus digits (plus 2), weighted by where it sits in the name (index plus 7). The sum modulo 49 is added to 127, so the hue is always between 127 and 175: the green family, 151 plus or minus 24. Saturation is fixed at 54% and lightness at 32%. "bob" gives 21 + 128 + 27 = 176, 176 mod 49 = 29, hue 156. The same name always gets the same disc. The source comment says the range sits around the desktop app's identicon hue, and that white on every hue in the range keeps at least 4.5:1 contrast.
Sizes and the capped initial
Size | Where | Initial |
|---|---|---|
56 | Headers: the current identity on Me, Identity detail, the Author header |
|
40 |
| |
28 | Rows and inline: document byline, comments, agents, other identities |
|
20 |
|
The rule in code is size >= 48 for the large initial. The circle keeps its size at every text size, so the letter is capped with font-size="min(-exact-title2, 24px)" or min(-exact-footnote, 12px): it grows with Dynamic Type only until it would leave the disc. See Accessibility.
Used by
Where | Size | Line |
|---|---|---|
FacePile, overlapping faces on cards and embeds | 20 | |
Document, the byline, one per author, each a link to the author | 28 | |
56 | ||
DiscussBubble, so every comment on Document, Thread and All comments | 28 | |
Activity inbox, each activity row | 40 | |
Agents list, each agent row, always the initial ( | 28 | |
Me, the current identity row | 56 | |
Me, other identities | 28 | |
Identity detail, the header row | 56 |
vault.contract imports Avatar and does not call it: the Vault identity rows have no avatar.
Rules for use
Pass a name a person would recognise. The callers resolve profile name, then key name, then short id before calling (Names, not identifiers).
Use 56 for the one header avatar of a screen and 28 in rows. 20 and 40 each have a single owner.
Do not wrap it in a border or a coloured ring. FacePile is the only caller that adds one, to separate overlapping faces.
Do not add a tap of its own. Where an avatar is tappable (the byline), the caller wraps it in a link with a 44 point target.
Why it looks this way
DESIGN.md asks for "Circle; initials on -exact-fill when no image": a neutral grey disc. The built component is green with a white initial, picked from the name. The file comment gives the reason: the same author keeps the same disc, as in the React Native app's hueFor, and the green family ties people to the Seed brand teal (Color and tokens). The screenshots in final/ still show the grey disc and are older; the fixes/ screenshots above show the built look. DESIGN.md also lists only sizes 28 and 56; the code adds 20 and 40.
Related
Parent: Shared components
StatusLine, the other shared component
Symbols and icons, Light and dark (the disc colour is the same in both schemes)
How it is built: Shared components and visual design
Do you like what you are reading? Subscribe to receive updates.
Unsubscribe anytime