Skip to main content
Version: Next

Avatar

The Avatar component can display an image or initials in a circular or rounded rectangle shape. It also has a customizable badge that can be positioned at the top or bottom of the Avatar, and can display text or an icon. This component can be used in various applications that require a user profile picture or initials, such as social media or messaging apps.

Import

import { Avatar } from '@tra-tech/react-native-kitra';

Usage

import { Avatar,Icon } from '@tra-tech/react-native-kitra';
import { View } from 'react-native';

const App = () => (
<View style={{ alignItems: 'center', flexDirection: 'row' }}>
<Avatar
variant="circular"
size="medium"
source={{ uri: 'https://randomuser.me/api/portraits/men/62.jpg' }}
/>
</View>
);

export default App;

Props

Prop nameTypeRequiredDescription
size'small' | 'medium'NoThe size of the avatar. Default value: 'medium'
sourceImageSourcePropTypeNoUsed to specify the image source.
variant'circular' | 'rounded'NoSpecifies the border type of the avatar. Default value: 'circular'
avatarIconReact.ReactNode NoUsed to add icon to avatar.
containerStyleStyleProp<ViewStyle>NoAdditional styles to apply to the avatar container.
labelstringNoRepresents the initials of the name to be written on the avatar.
labelStyleStyleProp<TextStyle>NoAdditional styles to apply to the label text.
themeUITheme NoThe theme to use for the component.
typography``UITypography

Avatar Group

The Avatar Group, used to list avatars side by side.

Import

import { AvatarGroup } from '@tra-tech/react-native-kitra';

Usage

import { AvatarGroup } from '@tra-tech/react-native-kitra';
import { View } from 'react-native';

const App = () => (
<View style={{ alignItems: 'center', flexDirection: 'row', marginTop: 30 }}>
<AvatarGroup
avatarLimit={5}
limitContainerStyle={{ backgroundColor: '#82B98E', style: { fontSize: 10 } }}
avatars={[
{ source: { uri: 'https://randomuser.me/api/portraits/men/62.jpg' } },
{ source: { uri: 'https://randomuser.me/api/portraits/men/40.jpg' } },
{ source: { uri: 'https://randomuser.me/api/portraits/women/26.jpg' } },
{ label: 'Dogus Erdem' },
{ label: 'Ahmet Kagan Yoruk' },
{ label: 'Nadire Kasap' },
]}
/>
</View>
);
export default App;

Props

Prop nameTypeRequiredDescription
avatarsArray<{
source?: ImageSourcePropType,
variant?: 'circular' | 'rounded',
avatarIcon?: React.ReactNode,
containerStyle?: StyleProp<ViewStyle>,
label?: string,
labelStyle?: StyleProp<TextStyle>,
textStyle?: StyleProp<TextStyle> },
}>
YesTakes avatar props into array.
avatarLimitnumberNoLimit of avatars to be listed. Default value: 10
limitContainerStyle'circular' | 'rounded'NoAdditional styles to apply to the limit container.
themeUITheme NoThe theme to use for the component.
typographyUITypography NoThe typography to use for the component.