Avatar
Avatar is used to show a profile picture or a text picture.
Examples
Basic Avatar
Basic avatar can be customized using various props such as size
, source
, title
, intent
,... See the below props table for more details.
Avatar.Stack
Avatar.Stack comes in two variants: horizontal
and vertical
.
Custom Avatar.Stack
The number of Avatars being displayed can be controlled using the max
prop, and the surplus value can be controlled by the total
prop.
When both props are set, the number of avatars will prioritize the max
prop, and the surplus value will prioritize the total
prop.
Avatar.Stack with custom surplus
Avatar surplus can be further customized by using the renderSurplus
render function.
useAvatarColors
Avatar support a hook called useAvatarColors
to randomize a group of single avatar colors in a stable way.
Fallback to text when image failed to load
Text Avatar with different sizes and intents
Avatar comes with 5 primary intents, success
, warning
, danger
, and info
.
Pressable avatar
Avatar Props
Prop | Required | Default | Type | |
---|---|---|---|---|
intent | primary | "warning" | "success" | "info" | "primary" | "danger" | ||
onPress | () => void | |||
size | small | "small" | "medium" | "large" | "xlarge" | "xxlarge" | "xxxlarge" | "xxxxlarge" | "xxxxxlarge" | ||
source | ImageSourcePropType | |||
style | StyleProp<ViewStyle> | |||
testID | string | |||
title | string |
Avatar.Stack Props
Prop | Required | Default | Type | |
---|---|---|---|---|
children | required | ReactElement<Omit<AvatarProps, "style" | "size">, string | JSXElementConstructor<any>>[] | ||
max | number | |||
renderSurplus | (value: number) => ReactNode | |||
size | small | "small" | "medium" | "large" | "xlarge" | "xxlarge" | "xxxlarge" | "xxxxlarge" | "xxxxxlarge" | ||
style | StyleProp<ViewStyle> | |||
testID | string | |||
total | number | |||
variant | horizontal | "horizontal" | "vertical" |