ExpoStartup

Avatar

A component for displaying user images or initials in a circular format.

Avatar

A component that displays user images or initials in a circular format with various size options.

Import

import Avatar from '@/components/Avatar';

Features

  • Image display with fallback to initials
  • Multiple size options (xxs to xxl)
  • Optional border styling
  • Interactive with press handlers or links
  • Background color customization
  • Dark mode support

Props

PropTypeDefaultDescription
srcstringURI of the image to display
namestringName for generating initials when no image is provided
size'xxs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl''md'Size of the avatar
borderbooleanfalseWhether to show a border
bgColorstring'bg-light-secondary dark:bg-dark-secondary'Background color (Tailwind class)
onPress() => voidFunction called when pressed
linkstringNavigation link when pressed
classNamestringAdditional Tailwind classes
styleViewStyleReact Native style object

Basic Usage

// Basic avatar with image
<Avatar 
  src="https://example.com/profile.jpg" 
  size="md"
/>
 
// Avatar with initials as fallback
<Avatar 
  name="John Doe" 
  size="lg"
/>
 
// Interactive avatar for navigation
<Avatar 
  src="https://example.com/profile.jpg" 
  link="/profile"
  border
/>
 
// Custom styling
<Avatar 
  name="Jane Smith" 
  size="xl" 
  bgColor="bg-purple-500" 
/>

On this page