Skip to main content

Single Avatar

API

import Avatar from '@flexnative/avatar';

Component

A React PureComponent that renders an avatar component with various customization options.

Avatar

Type: React.PureComponent<AvatarProps>

Props

Properties for the Avatar component.

AvatarProps

info

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

NameTypeRequiredDefault ValueDescription
typeTypetrueimageDefines the type of avatar to be displayed. image, icon and text are supported.
fillModeFillModefalsesolidRepresents the fill mode for an avatar component.
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

Defines the type of avatar to be displayed. One of 'image' | 'icon' | 'text'

NameTypeDescription
imagestringAn avatar that displays an image.
iconstringAn avatar that displays an icon.
textstringAn avatar that displays text.

FillMode

Represents the fill mode for an avatar component. One of 'solid' | 'none' | 'ghost'

NameTypeDescription
solidstringThe avatar will have a solid fill.
nonenoneThe avatar will have no fill.
ghostghostThe avatar will have a ghost fill.
warning
To have good appearance for 'ghost', with custom color you should use hex colors.

Sizes

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

NameTypeValue
smallnumber24
mediumnumber40
largenumber64
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...