Avatar

PreviousNext

An image element with a fallback for representing the user.

Installation

pnpm dlx bna-ui add avatar

Usage

import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
<Avatar>
  <AvatarImage
    source={{ uri: 'https://avatars.githubusercontent.com/u/99088394?v=4' }}
  />
  <AvatarFallback>AB</AvatarFallback>
</Avatar>

Examples

Default

Sizes

Fallback Only

Custom Styling

Group

With Status

Bordered

API Reference

Avatar

The container component that wraps the avatar image and fallback.

PropTypeDefaultDescription
childrenReactNode-The avatar image and fallback components.
sizenumber40The size of the avatar in pixels.
styleViewStyle-Additional styles to apply to the avatar container.

AvatarImage

The image component that displays the user's avatar.

PropTypeDescription
sourceImageSourceThe image source for the avatar.
styleImageProps.styleAdditional styles to apply to the image.

AvatarFallback

The fallback component that displays when the image fails to load or is not provided.

PropTypeDescription
childrenReactNodeThe fallback content (usually initials or text).
styleViewStyleAdditional styles to apply to the fallback container.
textStyleTextStyleAdditional styles to apply to the fallback text.

Accessibility

The Avatar component is built with accessibility in mind:

  • Uses semantic structure for screen readers
  • Fallback text provides alternative content when images fail to load
  • Proper contrast ratios for text fallbacks
  • Supports dynamic text sizing