An avatar component with a fallback for initials.
import { Avatar } from '@backstage/ui';
<Avatar
src="https://avatars.githubusercontent.com/u/1540635?v=4"
name="Charles de Dreuille"
/>| Prop | Type | Default | Responsive |
|---|---|---|---|
| src | string | - | No |
| name | string | - | No |
| size | x-smallsmallmediumlargex-large | medium | Yes |
| purpose | informativedecoration | informative | No |
| className | string | - | No |
| style | CSSProperties | - | No |
Avatar sizes can be set using the size prop.
<Flex gap="4" direction="column">
<Avatar
src="https://avatars.githubusercontent.com/u/1540635?v=4"
name="Charles de Dreuille" size="x-small"
/>
<Avatar
src="https://avatars.githubusercontent.com/u/1540635?v=4"
name="Charles de Dreuille" size="small"
/>
<Avatar
src="https://avatars.githubusercontent.com/u/1540635?v=4"
name="Charles de Dreuille" size="medium"
/>
<Avatar
src="https://avatars.githubusercontent.com/u/1540635?v=4"
name="Charles de Dreuille" size="large"
/>
<Avatar
src="https://avatars.githubusercontent.com/u/1540635?v=4"
name="Charles de Dreuille" size="x-large"
/>
</Flex>If the image is not available, the avatar will show the initials of the name.
<Avatar
src="https://avatars.githubusercontent.com/u/15406AAAAAAAAA"
name="Charles de Dreuille"
/>purpose prop#Control how the avatar is announced to screen readers using the purpose prop.
Our theming system is based on a mix between CSS classes, CSS variables and data attributes. If you want to customise this component, you can use one of these class names below.
bui-AvatarRootbui-AvatarRoot[data-size="small"]bui-AvatarRoot[data-size="medium"]bui-AvatarRoot[data-size="large"]bui-AvatarImagebui-AvatarFallback0.9.0 - BREAKING: Migrated Avatar component from Base UI to custom implementation with size changes:
Base UI-specific props are no longer supported
Size values have been updated:
x-small size added (1.25rem / 20px)small size unchanged (1.5rem / 24px)medium size unchanged (2rem / 32px, default)large size changed from 3rem to 2.5rem (40px)x-large size added (3rem / 48px)Migration:
# Remove Base UI-specific props
- <Avatar src="..." name="..." render={...} />
+ <Avatar src="..." name="..." />
# Update large size usage to x-large for same visual size
- <Avatar src="..." name="..." size="large" />
+ <Avatar src="..." name="..." size="x-large" />
Added purpose prop for accessibility control ('informative' or 'decoration'). #31566