Reference
Avatar
A picture of a person, or their initials.
Avatar(src: String, alt: String, initials: String, …)
Before 5.0
src
alt
size
tone
Example
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
Row(gap: .sm, align: .center) {
Avatar(initials: "AL").primary
Stack(gap: .xs) { Text("Ada Lovelace").bold Text("Maintainer").muted.sm }
}
Every size
Row(gap: .sm, align: .center) {
Avatar(initials: "SM").sm
Avatar(initials: "MD").md
Avatar(initials: "LG").lg
}
Props
| Prop | Type | Unset | Meaning |
|---|---|---|---|
src: | String | none | The picture's address, cropped to the circle; a |
alt: | String |
| What the picture shows, its |
initials: | String | none | The letters shown when there is no |
size: | one of its cases |
| How large the circle is. Written as a flag,
|
tone: | one of its cases | none: the full theme's primary already; plain under | The colour behind the initials. Written as a flag,
|
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.