Avatar
User avatars for displaying profile pictures, initials, or icons. Use avatars to represent users, teams, or entities.
Overview
Avatars are visual representations of users or entities. The Avatar component supports multiple content types, sizes, shapes, and color variants to fit different contexts and use cases.
All avatar styles are built using design tokens, ensuring consistency across themes and hues. Use the interactive playground below to explore all available combinations.
Interactive Playground
Use the controls to customize the avatar and see how it looks in real-time. Toggle between themes and hues to see how avatars adapt to different contexts.
<Avatar />Anatomy
An avatar consists of a container that holds the content (icon, text, or image).
width, height, border-radiusicon, text, or image--bg-*-solid or --bg-*-tonalVariants & States
Avatars come in different shapes, sizes, content types, and color variants to fit various use cases.
Icon
Use icons for generic user representation or when no specific user data is available.
Text
Use initials or short text when you want to display user names without images.
Image
Use profile images for personalized user representation. Includes fallback handling.
Round & Stroke
Default corner radius is 8px. Toggle to make fully round or add stroke border.
For a complete matrix of all avatar variants, sizes, and colors, see the Avatar component in Figma.
Usage Guidelines
- Use avatars to represent users, team members, or entities.
- Use appropriate sizes based on context and importance.
- Provide meaningful initials (2 characters) for text avatars.
- Use images when available for better personalization.
- Ensure sufficient color contrast for accessibility.
- Use consistent avatar styles throughout your application.
- Don't use avatars for decorative purposes only.
- Don't use more than 2 characters for text avatars.
- Don't use low-quality or inappropriate images.
- Don't mix avatar shapes inconsistently in the same context.
- Don't use avatars that are too small to recognize.
- Don't forget to provide alt text for image avatars.
Accessibility
- Provide descriptive alt text for image avatars using the
altattribute. - Ensure sufficient color contrast between background and content.
- Use meaningful initials that help identify the user.
- Consider using ARIA labels when avatars are interactive.
- Ensure avatars are large enough to be recognizable (minimum 32px).
API Reference
Avatar component props and types.
AvatarProps
interface AvatarProps {
size?: "sm" | "md" | "lg" | "xl";
type?: "icon" | "text" | "image";
color?: "primary" | "neutral" | "success" | "critical" | "warning";
variant?: "solid" | "faded";
isRound?: boolean;
hasStroke?: boolean;
initials?: string;
imageUrl?: string;
icon?: ComponentType<IconProps>;
alt?: string;
}Props
size"sm" | "md" | "lg" | "xl""md"type"icon" | "text" | "image""icon"color"primary" | "neutral" | "success" | "critical" | "warning""primary"variant"solid" | "faded""solid"isRoundbooleanfalsehasStrokebooleanfalseinitialsstring"JD"imageUrlstringiconComponentType<IconProps>altstringUsage Examples
Copyable code snippets for common avatar use cases.
Basic Avatar
import { Avatar } from 'beacon-ui';
<Avatar />Custom Icon
import { Avatar } from 'beacon-ui';
import { UserCircleIcon, SettingsGearIcon } from '@/components/icons';
<Avatar type="icon" icon={UserCircleIcon} />
<Avatar type="icon" icon={SettingsGearIcon} color="success" />Text Avatar
import { Avatar } from 'beacon-ui';
<Avatar type="text" initials="JD" />Image Avatar
import { Avatar } from 'beacon-ui';
<Avatar
type="image"
imageUrl="/images/avatars/avatar-female.png"
alt="User avatar"
/>Sizes
import { Avatar } from 'beacon-ui';
<Avatar size="sm" />
<Avatar size="md" />
<Avatar size="lg" />
<Avatar size="xl" />Round & Stroke
import { Avatar } from 'beacon-ui';
<Avatar />
<Avatar isRound />
<Avatar hasStroke />
<Avatar isRound hasStroke />Colors & Variants
import { Avatar } from 'beacon-ui';
<Avatar color="primary" variant="solid" />
<Avatar color="success" variant="faded" />
<Avatar color="neutral" variant="solid" />