Avatar
Usage
Placeholder
If src
prop is not set, equals to null or image cannot be loaded, placeholder icon will be rendered instead.
Any React node can be used instead of placeholder icon. Usually icon or initials are used in this case:
Size and radius
Control avatar width and height with size
and border-radius with radius
.
Both props have predefined values: xs, sm, md, lg, xl.
Alternatively, a number can be used to set radius or size in px:
Change root element
With custom component (react router example):
To use a custom component with TypeScript, pass an additional type:
Avatars Group
Use AvatarsGroup to stack avatar components, set limit
prop to truncate avatars:
To override truncated avatars length set total
prop:
Accessibility
Avatar renders img html element. It is important to add alt text.
If image fails to load alt will be used as title
for placeholder.