Avatar
Usage
Avatar represents a person or entity as a profile image or initials. Use it to identify users in lists, headers, menus, and chat threads, with an image when recognition matters and a profile picture is available, or initials as a lightweight fallback.
import { MtAvatar } from "@shopware-ag/meteor-component-library";
Examples
Sizes
With image
Square
All background colors
The background color is derived from the provided name, so repeated names get a stable color.
API reference
Props
| Prop | Type | Default |
|---|---|---|
size | "m" | "l" | "s" | "2xs" | "xs" | "m" |
first-name | string | undefined |
last-name | string | undefined |
image-url | string | undefined |
variant | "circle" | "square" | "circle" |
Slots
| Slot | Bindings |
|---|---|
default | {} |
Best practices
Do
- Provide an
imageUrlwhen possible, photos improve recognition. - Rely on initials when no image is available, they are concise and readable.
- Pick a size that fits the layout, for example
sfor dense lists orlfor profile headers. - Use the
squarevariant when the surrounding UI uses sharper corners.
Don't
- Do not treat Avatar as a clickable element, wrap it in a button or link if interaction is required.
- Do not place long text inside Avatar, it should only contain initials or an image.
- Do not oversize Avatar in dense layouts, this harms scanability.
Behavior
- If no
imageUrlis provided, Avatar falls back to initials derived fromfirstNameandlastName. - The background color is derived from the provided name, which gives repeated names a stable visual treatment.
- Avatar is presentational. If the avatar should trigger an action, place it inside an interactive wrapper instead of making the avatar itself responsible for interaction.
Accessibility
- If the avatar is only decorative, keep it out of the interaction flow.
- If the avatar represents an important person or entity, make sure the surrounding UI still exposes that identity in text.
- When wrapping the avatar in an interactive control, ensure the control has a clear accessible name.