Avatar
A small account image that falls back to the account’s initials.
Import
Section titled “Import”<script> import Avatar from "@invisible-ui/svelte/Avatar.svelte";</script><script setup> import { Avatar } from "@invisible-ui/vue";</script>import { Avatar } from "@invisible-ui/react";<script type="module"> import "@invisible-ui/elements/define";</script>
<ds-avatar></ds-avatar>In Elements:
<ds-avatar name="Ada Lovelace" src="/ada.png" size="lg"></ds-avatar>| Prop | Type | Default | Description |
|---|---|---|---|
name * | string | — | Provides the accessible name and the initials fallback. |
src | string | undefined | undefined | Image URL; when absent or it fails to load, initials are shown. |
alt | string | undefined | undefined | Accessible name; defaults to name. |
size | "sm" | "md" | "lg" | "md" | Avatar size. |
shape | "circle" | "square" | "circle" | Avatar shape. |
| Prop | Type | Default | Description |
|---|---|---|---|
name * | string | — | Required: accessible name + initials fallback. |
src | string | undefined | Image URL. When absent or it fails to load, initials are shown. |
alt | string | undefined | Accessible name; defaults to name. |
size | "sm" | "md" | "lg" | "md" | |
shape | "circle" | "square" | "circle" |
| Prop | Type | Default | Description |
|---|---|---|---|
name * | string | — | Required: the accessible name and the source of the initials. |
src | string | — | Image URL. When absent or it fails to load, the initials show. |
alt | string | — | Accessible name; defaults to name. |
size | "sm" | "md" | "lg" | "md" | |
shape | "circle" | "square" | "circle" |
| Attribute | Reactive | Description |
|---|---|---|
name * | yes | : the accessible name and the initials |
src | yes | |
alt | yes | overrides the accessible name |
size | yes | sm|md|lg |
shape | yes | circle|square |
Reactive attributes re-render the element when they change after the first render.
The image src is rendered as given: pass only URLs you trust or have
sanitized. See Security.
Accessibility
Section titled “Accessibility”- Exposed as a single image (
role="img"+aria-label), so it reads the same whether the photo or initials show.
Example
Section titled “Example”<Avatar name="Ada Lovelace" src="/ada.jpg" size="lg" />In React:
<Avatar name="Ada Lovelace" src="/ada.jpg" size="lg" />Themeable via --ds-avatar-*.