Usage
MK
Placeholder
If src prop is not set, equals to null or image cannot be loaded, placeholder icon will be displayed instead.
Any React node can be used instead of placeholder icon. Usually icon or initials are used in this case:
VR
Size and radius
Variant
Radius
xs
sm
md
lg
xl
Size
xs
sm
md
lg
xl
Color
Change root element
With custom component (react router example):
Avatar.Group
Avatar.Group component can be used to combine multiple avatars into a stack:
+5
You can combine it with Tooltip or Popover to show additional information on hover
+2
Accessibility
Avatar renders img html element. Do not forget to add alt text.
If image fails to load alt will be used as title for placeholder.
Avatar component props
| Name | Type | Description |
|---|---|---|
| alt | string | Image alt text or title for placeholder variant |
| children | ReactNode | Custom placeholder |
| color | MantineColor | Color from theme.colors used for letter and icon placeholders |
| gradient | MantineGradient | Controls gradient settings in gradient variant only |
| imageProps | Record<string, any> | img element attributes |
| radius | number | "xs" | "sm" | "md" | "lg" | "xl" | Value from theme.radius or number to set border-radius in px |
| size | number | "xs" | "sm" | "md" | "lg" | "xl" | Avatar width and height |
| src | string | Image url |
| variant | "outline" | "light" | "filled" | "gradient" | Controls appearance |
Avatar.Group component props
| Name | Type | Description |
|---|---|---|
| children * | ReactNode | Avatar components |
| spacing | number | "xs" | "sm" | "md" | "lg" | "xl" | Negative space between Avatars |
Avatar component Styles API
| Name | Static selector | Description |
|---|---|---|
| root | .mantine-Avatar-root | Root element |
| image | .mantine-Avatar-image | Main img tag, rendered when src is set to valid image url |
| placeholder | .mantine-Avatar-placeholder | Placeholder element, rendered when src is null or image cannot be loaded |
| placeholderIcon | .mantine-Avatar-placeholderIcon | Default placeholder icon |