Reference

Avatar

A picture of a person, or their initials.

Avatar(src: String, alt: String, initials: String, …)

Before 5.0

src

alt

size

tone

Ada Lovelace
GH
AT

Example

wf

Row(gap: .md, align: .center) { Avatar(src: "/icon-512.png", alt: "Ada Lovelace").lg Avatar(initials: "GH").primary Avatar(initials: "AT").sm }

Beside a name

wf

Row(gap: .sm, align: .center) { Avatar(initials: "AL").primary Stack(gap: .xs) { Text("Ada Lovelace").bold Text("Maintainer").muted.sm } }

Every size

wf

Row(gap: .sm, align: .center) { Avatar(initials: "SM").sm Avatar(initials: "MD").md Avatar(initials: "LG").lg }

Props

Props of Avatar
PropTypeUnsetMeaning

src:

String

none

The picture's address, cropped to the circle; a data:image/… address is taken. With it, initials: is not shown

alt:

String

""

What the picture shows, its alt; empty for a picture the name beside it already says

initials:

String

none

The letters shown when there is no src:

size:

one of its cases

md

How large the circle is. Written as a flag, .sm, or by name, size: .sm.

  • .sm: 32px
  • .md (the default): 40px, the default
  • .lg: 56px

tone:

one of its cases

none: the full theme's primary already; plain under theme.builtin: "structural"

The colour behind the initials. Written as a flag, .primary, or by name, tone: .primary.

  • .primary: The theme's primary colour, the initials in color-on-primary

Attribute families: global, aria, data. Plus the 22 universal props every element takes: animate:, exit:, speed:, duration:, delay:, easing:, stagger:, on:, count:, shared:, class:, ref:, drag:, dragGroup:, dropValue:, dropAxis:, dropInside:, roving:, trapFocus:, mount:, update:, cleanup:.

Flags and cases

A flag is written after the parentheses with a dot: a Bool prop, or a case of one of the element's enum props. A case the enum lacks is an error with a hint.

.sm

.md

.lg

.primary

Events

Every element also takes the props, the events and the attribute families listed on every element.

Slots

It takes no slots.

Renders with the class wf-avatar, stable across releases, so a stylesheet may target it.