PUI. Avatar
(pui v1.0.0)
Copy Markdown
An avatar with a host-controlled fallback.
Avatar renders an image when src is present and the fallback when it is not.
It deliberately does not add a JavaScript error handler; applications that
need a fallback after a failed remote image request can own that behavior
through the forwarded global attributes.
Examples
<.avatar src={@user.avatar_url} alt={@user.name} fallback_text="SC" />
<.avatar alt="Team" size="lg">
<:fallback>TM</:fallback>
</.avatar>Attributes
| Name | Type | Default | Description |
|---|---|---|---|
src | string | nil | Image source; fallback renders when absent |
alt | string | "" | Image alternative text |
fallback_text | string | nil | Text shown when no image exists |
size | string | "default" | "sm", "default", or "lg" |
class | string | "" | Additional CSS classes |
rest | global | — | Global HTML attributes |
Slots
| Slot | Required | Description |
|---|---|---|
fallback | no | Custom fallback content |