Skip to main content

Single Avatar

API

import Avatar from '@flexnative/avatar';

Component

Avatar

Type: React.PureComponent<AvatarProps>

Props

info

AvatarProps of @flexnative/avatar package extends ImageProps | TextProps.

NameTypeRequiredDefault ValueDescription
typeTypetrueimageAvatar Type. image, icon and text are supported
fillModeFillModefalsesolidFill Mode
radiusBorderRadiusfalsefullAvatar border radius.
sizeSizesfalsemediumAvatar Size.
backgroundColorColorValuefalseundefinedBackground color according react-native ColorValue.
borderColorColorValuefalseundefinedBorders color according react-native ColorValue.
colorColorValuefalsedefaultColor by theme or a custom color according react-native ColorValue.
borderWidthBorderWidthfalsenoneOptional avatar borders width.
textstringfalseundefinedText to display on avatar for type Type = 'text'
textColorColorValuefalseundefinedText color according react-native ColorValue. Available for Type = 'text'
iconIconNamefalseundefinedName of icon. Icon props for Avatar Type = 'icon'
iconColorColorValuefalseundefinedIcon color according react-native ColorValue. Available for Type = 'icon'

Type

One of 'image' | 'icon' | 'text'

NameTypeDescription
imagestringProperty to render image on avatar component.
iconstringProperty to render icon on avatar component.
textstringProperty to render text on avatar component.

FillMode

One of 'solid' | 'none' | 'ghost'

NameTypeDescription
solidstringProperty to fill in solid mode the bac of avatar component.
outlineoutlineProperty to set transparent background avatar component width borders.
ghostghostProperty to fill in the background of avatar component with a transparent color.
warning
To have good appearance for 'ghost', with custom color you should use hex colors.

BorderRadius

One of 'none' | 'small' | 'medium' | 'large' | 'full' | number

NameTypeValue
nonenumber0
smallnumber2
mediumnumber4
largenumber6
fullnumber99999
numberAny number value.

Sizes

One of 'small' | 'medium' | 'large' | number

NameTypeValue
smallnumber24
mediumnumber40
largenumber64
numberAny number value

BorderWidth

One of 'none' | 'hairline' | 'thin' | 'base' | 'thick' | number

NameTypeValue
nonenumber0
hairlineStyleSheet.hairlineWidthThis is defined as the width of a thin line on the platform. It can be used as the thickness of a border or division between two elements.
thinnumber1
basenumber2
thicknumber3
numberAny number value.

Usecase Examples

The following example demonstrates the different types of Avatar in action.

Image Type

Icon Type

Text Type

R A
R A
R A
R A
R A
R A
R A
R A
R A
R A
R A
R A
R A

Playground

Live Editor
//Play with props to see live changes;

render(<Avatar source={LOGO} size={120} color='primary' borderWidth='thin' fillMode='ghost' borderColor='crimson'/>);
Result
Loading...