# Avatar

- **Section:** Components
- **URL:** https://refast.fastapicloud.dev/docs/components/avatar
- **Markdown:** https://refast.fastapicloud.dev/docs/components/avatar.md
- **Source:** https://github.com/idling-mind/refast-docs/blob/main/docs/pages/components/data_display/avatar.py
- **Live examples:** the widgets on this page need a browser; open the URL above to try them.
- **Applies to:** refast 0.12.2

Circular user image with an initials fallback. When the image is absent or
fails to load, the `fallback` string is shown instead.

```python
from refast.components import Avatar

# Image avatar
Avatar(src="/avatars/alice.jpg", alt="Alice", size="md")

# Initials-only avatar
Avatar(fallback="JD", size="lg")
```

```python
Avatar(
    src="https://api.dicebear.com/7.x/avataaars/svg?seed=john",
    alt="John Doe",
    fallback="JD",
    size="md",
)
```

## Props

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `src` | `str \| None` | `None` | URL of the user image. Omit to show initials only. |
| `alt` | `str` | `""` | Alternative text; also used to derive the fallback initial when `fallback` is not supplied. |
| `fallback` | `str \| None` | `None` | Short string (one or two letters) shown when the image is unavailable. |
| `size` | `"sm" \| "md" \| "lg"` | `"md"` | Avatar diameter: `"sm"` = 32px, `"md"` = 40px, `"lg"` = 48px. |
| `class_name` | `str` | `""` | Extra Tailwind classes. |

## All sizes

```python
Row(gap=4, children=[
    Avatar(fallback="SM", size="sm"),
    Avatar(fallback="MD", size="md"),
    Avatar(fallback="LG", size="lg"),
])
```

## With image

```python
Avatar(src="/avatars/alice.jpg", alt="Alice Johnson", size="lg")
```

## Initials fallback

```python
# Fallback derived from alt text
Avatar(alt="John Doe", size="md")       # shows "J"

# Explicit fallback string
Avatar(fallback="JD", size="md")        # shows "JD"
```

## In a user profile card

```python
Row(
    align="center",
    gap=3,
    children=[
        Avatar(src="/avatars/alice.jpg", alt="Alice", size="lg"),
        Column(gap=0, children=[
            Text("Alice Johnson", class_name="font-semibold"),
            Text("alice@example.com", class_name="text-sm text-muted-foreground"),
        ]),
    ],
)
```

---

Part of the Refast documentation: [all pages](https://refast.fastapicloud.dev/llms.txt), [everything on one page](https://refast.fastapicloud.dev/llms-full.txt), [search](https://refast.fastapicloud.dev/api/search?q=save_prop).
