BNA

BNA UI
26

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.

PropTypeDefaultDescription
sourceImageSource-The image source for the avatar.
styleImageProps.style-Additional styles to apply to the image.

AvatarFallback

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

PropTypeDefaultDescription
childrenReactNode-The fallback content (usually initials or text).
styleViewStyle-Additional styles to apply to the fallback container.
textStyleTextStyle-Additional 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