Avatar component is used to represent a user and it can display a profile picture, initials or a fallback icon.
NativeBase exports 3 avatar-related components:
Avatar: An image that represents the user.
Avatar.Badge: A wrapper that displays its content on the bottom right corner of the avatar.
Avatar.Group: A wrapper to stack multiple avatars together.
import { Avatar } from 'native-base';
const Example = () => {
return <HStack space={2}>
<Avatar source={{
uri: "https://pbs.twimg.com/profile_images/1188747996843761665/8CiUdKZW_400x400.jpg"
}}>
SS
</Avatar>
<Avatar source={{
uri: "https://pbs.twimg.com/profile_images/1177303899243343872/B0sUJIH0_400x400.jpg"
}}>
GG
</Avatar>
<Avatar source={{
uri: "https://pbs.twimg.com/profile_images/1352844693151731713/HKO7cnlW_400x400.jpg"
}}>
RS
</Avatar>
<Avatar source={{
uri: "https://pbs.twimg.com/profile_images/1309797238651060226/18cm6VhQ_400x400.jpg"
}}>
AK
</Avatar>
</HStack>;
};
const Example = () => {
return <Stack direction={{
base: "column",
md: "row"
}} space={1} alignItems={{
base: "center",
md: "flex-start"
}}>
<Avatar size="xs" source={{
uri: "https://pbs.twimg.com/profile_images/1188747996843761665/8CiUdKZW_400x400.jpg"
}}>
SS
</Avatar>
<Avatar size="sm" source={{
uri: "https://pbs.twimg.com/profile_images/929409889788510208/gRr2f7rZ_400x400.jpg"
}}>
HS
</Avatar>
<Avatar size="md" source={{
uri: "https://pbs.twimg.com/profile_images/1352844693151731713/HKO7cnlW_400x400.jpg"
}}>
RS
</Avatar>
<Avatar size="lg" source={{
uri: "https://pbs.twimg.com/profile_images/1309797238651060226/18cm6VhQ_400x400.jpg"
}}>
AK
</Avatar>
<Avatar size="xl" source={{
uri: "https://pbs.twimg.com/profile_images/1177303899243343872/B0sUJIH0_400x400.jpg"
}}>
GG
</Avatar>
<Avatar size="2xl" source={{
uri: "https://pbs.twimg.com/profile_images/1320985200663293952/lE_Kg6vr_400x400.jpg"
}}>
RB
</Avatar>
</Stack>;
};
const Example = () => {
return <HStack mx={{
base: "auto",
md: 0
}} space={2}>
<Avatar mr={1} source={{
uri: "https://bit.ly/broken-link"
}}>
RS
</Avatar>
<Avatar source={{
uri: "https://bit.ly/broken-link"
}}>
MR
</Avatar>
<Avatar source={{
uri: "https://bit.ly/broken-link"
}} />
</HStack>;
};
const Example = () => {
return <HStack mx={{
base: "auto",
md: 0
}} space={2}>
<Avatar source={{
uri: "https://alpha.nativebase.io/img/native-base-icon.png"
}}>
NB
<Avatar.Badge bg={"red.200"} />
</Avatar>
<Avatar source={{
uri: "https://alpha.nativebase.io/img/native-base-icon.png"
}}>
NB
<Avatar.Badge borderColor="papayawhip" bg="tomato" />
</Avatar>
</HStack>;
};
const Example = () => {
return <Avatar.Group size="lg" max={3}>
<Avatar source={{
uri: "https://pbs.twimg.com/profile_images/1369921787568422915/hoyvrUpc_400x400.jpg"
}}>
SS
</Avatar>
<Avatar source={{
uri: "https://pbs.twimg.com/profile_images/1309797238651060226/18cm6VhQ_400x400.jpg"
}}>
AK
</Avatar>
<Avatar source={{
uri: "https://pbs.twimg.com/profile_images/1352844693151731713/HKO7cnlW_400x400.jpg"
}}>
RS
</Avatar>
<Avatar source={{
uri: "https://pbs.twimg.com/profile_images/1320985200663293952/lE_Kg6vr_400x400.jpg"
}}>
MR
</Avatar>
<Avatar source={{
uri: "https://bit.ly/code-beast"
}}>
CB
</Avatar>
<Avatar source={{
uri: "https://pbs.twimg.com/profile_images/1177303899243343872/B0sUJIH0_400x400.jpg"
}}>
GG
</Avatar>
<Avatar source={{
uri: "https://pbs.twimg.com/profile_images/1352844693151731713/HKO7cnlW_400x400.jpg"
}}>
RS
</Avatar>
<Avatar source={{
uri: "https://pbs.twimg.com/profile_images/1320985200663293952/lE_Kg6vr_400x400.jpg"
}}>
MR
</Avatar>
</Avatar.Group>;
};
Avatar implements
,
,
,
,
,
,
,
,
,
,
,
,
Text styling for fallback text
Style to be passed in rendered Image component
The image source of the avatar.
ref to be attached to Avatar wrapper
Group implements
,
,
,
,
,
,
,
,
,
,
,
,
AvatarBadge implements
,
,
,
,
,
,
,
,
,
,
,
,
NativeBase ships with a default theme for each component. Check out the default theme of the avatar
.
Info:
We can easily extend the avatar component theme using extendTheme function as described in the documentation .