Avatar
A circular avatar with an image and initials fallback.
fandry-avatar
Example
Link to section ExampleCustom colors and parts
Link to section Custom colors and partsThe same component with a few --fd-* tokens set around it and its parts restyled. The code is under Parts below.
Props
Link to section Props| Prop | Type | Default | Description |
|---|---|---|---|
src | string | '' | Image URL — falls back to initials on error. |
initials | string | '' | Fallback initials. |
size | 'sm' | 'md' | 'lg' | 'md' | Avatar size. |
Parts
Link to section PartsStyle the elements inside the component from your own CSS with ::part(). Every fandry component renders in native shadow DOM, so parts work on LWR and Salesforce alike. For colors, spacing, radius and type across many components, set the --fd-* tokens instead. The code for the "Custom colors and parts" example above:
| Part | Description |
|---|---|
base | The outermost element. |
image | The <img>. |
initials | The initials shown when there is no image. |
<!-- template -->
<div class="brand row">
<fandry-avatar initials="AL" size="sm"></fandry-avatar>
<fandry-avatar initials="GH" size="md"></fandry-avatar>
<fandry-avatar initials="KJ" size="lg"></fandry-avatar>
</div>
/* css */
/* Scoped to this demo. Set the same --fd-* tokens on :root to theme
every fandry-* component on the site. */
.brand {
--fd-bg-muted: 160 40% 90%;
--fd-text-muted: 160 84% 22%;
}
fandry-avatar::part(base) {
border-radius: 0.75rem;
font-weight: 700;
}
fandry-avatar::part(initials) {
letter-spacing: 0.04em;
}
Code
Link to section Code<fandry-avatar initials="JD" size="md"></fandry-avatar>