# Avatar (`.z-avatar`)

> Image or initials avatar with rounded and bordered variants and a positionable status dot.

- **Kind:** css
- **Category:** general

## CSS Variables

| Variable | Default | Scope | Affects | Description |
| --- | --- | --- | --- | --- |
| `--z-avatar-bg` | `var(--z-bg)` | `.z-avatar` | `background-color` | Background behind the image or initials. |
| `--z-avatar-border` | `var(--z-border)` | `.z-avatar` | `border-color` | Border color of the bordered variant. |
| `--z-avatar-border-o` | `4%` | `.z-avatar` | `border-color` | Opacity applied to the bordered variant's border color. |
| `--z-avatar-dot-bg` | `var(--z-danger)` | `.z-avatar-dot-danger::after` | `background-color` | Background color of the status dot; the color variants set it per scheme. |
| `--z-avatar-dot-border` | `var(--z-bg)` | `.z-avatar-dot::after, .z-avatar-dot-top::after, .z-avatar-dot-top-right::after, .z-avatar-dot-right::after, .z-avatar-dot-bottom::after, .z-avatar-dot-bottom-right::after, .z-avatar-dot-bottom-left::after, .z-avatar-dot-left::after, .z-avatar-dot-top-left::after` | `border-color` | Ring color around the status dot. |
| `--z-avatar-dot-size` | `0.875rem` | `.z-avatar-dot::after, .z-avatar-dot-top::after, .z-avatar-dot-top-right::after, .z-avatar-dot-right::after, .z-avatar-dot-bottom::after, .z-avatar-dot-bottom-right::after, .z-avatar-dot-bottom-left::after, .z-avatar-dot-left::after, .z-avatar-dot-top-left::after` | `height`, `width` | Width and height of the status dot. |
| `--z-avatar-radius` | `var(--z-global-radius)` | `.z-avatar` | `border-radius` | Corner radius of the avatar container. |
| `--z-avatar-size` | `2.5rem` | `.z-avatar` | `height`, `width` | Width and height of the avatar. |

## CSS Classes

| Class | Role | Applies to | Description |
| --- | --- | --- | --- |
| `.z-avatar` | `root` | `.z-avatar` | Square avatar container for an image or initials. |
| `.z-avatar-bordered` | `modifier` | `.z-avatar` | Adds a border ring with inner padding around the avatar. |
| `.z-avatar-dot` | `modifier` | `.z-avatar` | Status dot at the bottom-right corner (the default position). |
| `.z-avatar-dot-bottom` | `modifier` | `.z-avatar` | Status dot centered on the bottom edge. |
| `.z-avatar-dot-bottom-left` | `modifier` | `.z-avatar` | Status dot at the bottom-left corner. |
| `.z-avatar-dot-bottom-right` | `modifier` | `.z-avatar` | Status dot at the bottom-right corner. |
| `.z-avatar-dot-danger` | `modifier` | `.z-avatar` | Danger-colored status dot. |
| `.z-avatar-dot-info` | `modifier` | `.z-avatar` | Info-colored status dot. |
| `.z-avatar-dot-left` | `modifier` | `.z-avatar` | Status dot centered on the left edge. |
| `.z-avatar-dot-muted` | `modifier` | `.z-avatar` | Muted-colored status dot. |
| `.z-avatar-dot-right` | `modifier` | `.z-avatar` | Status dot centered on the right edge. |
| `.z-avatar-dot-success` | `modifier` | `.z-avatar` | Success-colored status dot. |
| `.z-avatar-dot-top` | `modifier` | `.z-avatar` | Status dot centered on the top edge. |
| `.z-avatar-dot-top-left` | `modifier` | `.z-avatar` | Status dot at the top-left corner. |
| `.z-avatar-dot-top-right` | `modifier` | `.z-avatar` | Status dot at the top-right corner. |
| `.z-avatar-dot-warning` | `modifier` | `.z-avatar` | Warning-colored status dot. |
| `.z-avatar-rounded` | `modifier` | `.z-avatar` | Fully circular avatar and content. |
| `.z-avatar-text` | `element` | `.z-avatar` | Initials or text content filling the avatar. |

## Notes

- The status dot is a `::after` pseudo-element: combine one position class with one color class on the container.
- Images fill the container with `object-fit: cover`.

## Guides

- [Styling with cls and stl](https://next.0build.dev/docs/guides/styling.md)
- [Translating Components](https://next.0build.dev/docs/guides/i18n.md)
- [Icon Resolution](https://next.0build.dev/docs/guides/icons.md)
- [The data-source Convention](https://next.0build.dev/docs/guides/data-source.md)
- [Openers & Triggers](https://next.0build.dev/docs/guides/triggers.md)
- [Dialog Behavior](https://next.0build.dev/docs/guides/dialogs.md)
- [Utilities](https://next.0build.dev/docs/guides/utilities.md)
- [Runtime](https://next.0build.dev/docs/guides/runtime.md)
