Skip to main content

Avatar

#Avatar avatar component

Effect demonstration

1. Default avatar

<Avatar url="https://images.pexels.com/photos/1702238/pexels-photo-1702238.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=1000" />
default avatar ios

2. Avatar size

 <Avatar
size={20}
url="https://images.pexels.com/photos/1702238/pexels-photo-1702238.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=1000"
/>
<Avatar
size={40}
url="https://images.pexels.com/photos/1702238/pexels-photo-1702238.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=1000"
/>
<Avatar
size={60}
url="https://images.pexels.com/photos/1702238/pexels-photo-1702238.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=1000"
/>
avatar size ios

3. Avatar curvature

 <Avatar
circular={false}
url="https://images.pexels.com/photos/1702238/pexels-photo-1702238.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=1000"
/>
<Avatar
borderRadius={10}
circular={false}
url="https://images.pexels.com/photos/1702238/pexels-photo-1702238.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=1000"
/>
<Avatar
borderRadius={20}
circular={false}
url="https://images.pexels.com/photos/1702238/pexels-photo-1702238.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=1000"
/>
 ios

4. Avatar pendant

//Custom pendant is located at the top
<Avatar url="https://images.pexels.com/photos/1702238/pexels-photo-1702238.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=1000">
<Avatar.Accessory
component={<SvgIcon name="bells" color="green" size={24} />}
top={true}
left={true}
/>
</Avatar>
//Custom pendant position is on the upper left
<Avatar url="https://images.pexels.com/photos/1702238/pexels-photo-1702238.jpeg?auto=compress& cs=tinysrgb&dpr=1&w=1000">
<Avatar.Accessory
component={<SvgIcon name="bells" color="green" size={24} />}
left={true}
/>
</Avatar>
//Custom image
<Avatar url="https://images.pexels.com/photos/1702238/pexels-photo-1702238.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=1000">
<Avatar.Accessory url="https://images.pexels.com/photos/1702238/pexels-photo-1702238.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=1000" />
</Avatar>
avatar widget ios

5. Avatar content

//Custom content: use text
<Avatar title="123" />
//Custom content: use images
<Avatar url={require('../../../assets/images/icon.png')} />
//Custom content: use images
<Avatar url="https://images.pexels.com/photos/1702238/pexels-photo-1702238.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=1000" />
avatar content ios

6. Avatar group

<AvatarGroup max={4}>
<Avatar
url="https://images.pexels.com/photos/1702238/pexels-photo-1702238.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=1000"
circular
/>
<Avatar
url="https://images.pexels.com/photos/1702238/pexels-photo-1702238.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=1000"
circular
/>
<Avatar
url="https://i0.wp.com/fancycrave.com/wp-content/uploads/2020/03/group-of-diverse-friends-playing-game-on-mobile-P5BYNJM.jpg"
circular
/>
<Avatar
url="https://images.pexels.com/photos/1702238/pexels-photo-1702238.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=1000"
circular
/>
<Avatar
url="https://i0.wp.com/fancycrave.com/wp-content/uploads/2020/03/group-of-diverse-friends-playing-game-on-mobile-P5BYNJM.jpg"
circular
/>
</AvatarGroup>
头像组 ios

7. Avatar group background

<AvatarGroup max={4} backgroundColor="orange">
<Avatar
url="https://images.pexels.com/photos/1702238/pexels-photo-1702238.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=1000"
circular
/>
<Avatar
url="https://images.pexels.com/photos/1702238/pexels-photo-1702238.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=1000"
circular
/>
<Avatar
url="https://i0.wp.com/fancycrave.com/wp-content/uploads/2020/03/group-of-diverse-friends-playing-game-on-mobile-P5BYNJM.jpg"
circular
/>
<Avatar
url="https://images.pexels.com/photos/1702238/pexels-photo-1702238.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=1000"
circular
/>
<Avatar
url="https://i0.wp.com/fancycrave.com/wp-content/uploads/2020/03/group-of-diverse-friends-playing-game-on-mobile-P5BYNJM.jpg"
circular
/>
</AvatarGroup>
 ios

Avatar component API

PropertiesRequiredDescriptionTypeDefault Value
urlfalseThe path to the imagestring | number
sizefalseavatar sizenumberpx(46)
borderRadiusfalseAvatar curvaturenumber0
titlefalseTitle (text displayed in the avatar, cannot be used with url)string
circularfalseWhether the avatar is circularbooleantrue
backgroundColorfalseBackground when using titlestring#E5F1FF
textStylefalsetitle text styleTextStyle
containerStylefalseContainer styleViewStyle
activeOpacityfalseTransparency on clicknumber0.6
onPressfalseCallback event for clicking the avatar() => void

Accessory component API

PropertiesRequiredDescriptionTypeDefault Value
urlfalseThe path to the imagestring | number
sizefalseIcon sizenumberpx(14)
iconfalseprops when using iconIconProps
componentfalseUse custom componentsReactNode
topfalseThe vertical position of the pendantbooleanfalse
leftfalseThe horizontal position of the widgetbooleanfalse

AvatarGroup component API

PropertiesRequiredDescriptionTypeDefault Value
maxfalseMaximum number to displaynumber4
spacingfalseSpacing of avatarnumberpx(23)
backgroundColorfalseThe background of the number avatarstring#E5F1FF
textStylefalseQuantity avatar title text styleTextStyle