A person's photo, with their initials or an icon when there is no photo.
import { Avatar } from '@oztix/roadie-components/avatar'
Pass src and name. The initials from name show until the photo loads, and stay if it never does.
<Avatar src='/roadie-logo.png' name='Mia Tran' />
Sizes run xs to xl and match IconTile, so the two line up in a row. Initials and the icon scale with the box, so a custom size-* class works too.
Avatars are circles by default. Use shape='square' for an organisation or a team rather than a person. The corner radius grows with the size.
The fallback uses the subtle emphasis of the surrounding intent. Set intent to colour one avatar.
Without a photo, the avatar shows initials from the first and last words of name. Without a name, it shows a user icon. A photo that fails to load is hidden, so the fallback shows instead of a broken image.
Compose Avatar.Fallback and Avatar.Image yourself for custom fallback content. Put the fallback first so the photo paints over it. Give the fallback role='img' and an aria-label so it names the person until the photo loads.
Avatar.Image stays mounted while it loads, so loading='lazy' works and it can render through Roadie's Image. Oztix CDN photos then get a resized srcSet.
Avatar.Group overlaps its avatars and rings each one in the page colour. It sets the size and shape for every avatar inside it. End the row with Avatar.GroupCount for the people you don't show. Give the group an aria-label.
On a surface other than the page, set --avatar-ring to that surface so the rings still read as gaps.
Show who is signed in. The name is written beside the avatar, so pass alt='' to keep screen readers from reading it twice.
Avatars fit a List row's leading slot. The row title names the person, so the avatar is decorative.
<Avatar src={user.photo} name={user.name} />
Do
Pass name even with a photo. It gives the fallback its initials and the avatar its accessible name.
<Avatar src={user.photo} />
Don’t
Don't rely on the photo alone. If it fails, everyone gets the same icon.
Do
Use an avatar for a person, or a square one for an organisation with a logo or initials.
Don’t
Don't use an avatar to frame an icon for a setting or a category. Use IconTile.
name or alt, the avatar is announced as an image with that name, whether it shows the photo or the initials.alt='' when the name is already visible beside the avatar. The avatar is then hidden from screen readers.Avatar.GroupCount is announced as "12 more". Pass aria-label to say more, for example "12 more people going".CSS class applied to the element, or a function that returns a class based on the component's state.
Inherits from `Avatar.Group`, else `md`.
Inherits from `Avatar.Group`, else `circle`.
Colours the fallback; inherits from context when unset.
Image URL. Used when there are no children.
Person's name. Gives the fallback its initials and the avatar its name.
Accessible name, over `name`. Pass `''` when the name is already beside it.
CSS class applied to the element, or a function that returns a class based on the component's state.
Inherited from AvatarFallbackProps
How long to wait before showing the fallback. Specified in milliseconds.
Defaults to 0.
Set `--avatar-ring` to the surface behind the group when it isn't the page.
Size of every avatar in the group.
Defaults to md.
Shape of every avatar in the group.
Defaults to 'circle'.
The last item in an `Avatar.Group`. Announced as "N more" unless `aria-label` says otherwise.
How many people the group doesn't show. Renders as `+N`.
Inherits from `Avatar.Group`, else `md`.
Inherits from `Avatar.Group`, else `circle`.
Stays mounted so the image is in server HTML and `loading='lazy'` works; it stays hidden over the fallback until it loads.
CSS class applied to the element, or a function that returns a class based on the component's state.
Inherited from AvatarImageProps
Callback fired when the loading status changes.
Whether the image element stays mounted and loads in place instead of being preloaded. Supports `loading="lazy"` and optimized image components such as `next/image`.
Defaults to true.