Skip to Content
Archi-ui 1.0.25 is released 🎉

Avatar

Basic Avatar

Usage

import { Avatar } from 'archi-ui'
<Avatar />

Image Avatars

Image avatars can be created by passing standard img prop src to the component.

Eren Yeager
Mikasa Ackerman
Armin

Letter Avatars

Avatars containing simple characters can be created by passing a string as children

H
N
P
R

Variant

If you need square, rounded or circular avatars, use the variant prop.

S
R
C

Size

Use size prop to change the size of the Avatar.

Naruto
Naruto
Naruto

Icon avatars

Icon avatars can be created by passing an icon as children.

Avatar Fallback

If there is an error loading the avatar image, the component falls back to an alternative in the following order:

  • The provided children
  • the first letter of the alt text
  • a generic avatar icon - <User />
Eren Yeager
Mikasa Ackerman

Avatar Group

AvatarGroup renders its children as a stack. USe the max prop to limit the number of avatars.

Eren Yeager
Mikasa Ackerman
Armin
+2

Avatar Group control

You can controll the avatars shape, size, and outline from AvatarGroup component itself using variant, size, and outlined prop of AvatarGroup.

Eren Yeager
Mikasa Ackerman
Armin
Levi Ackerman
Eren Yeager
Mikasa Ackerman
Armin
Levi Ackerman
Eren Yeager
Mikasa Ackerman
Armin
Levi Ackerman

Total Avatars

If you need to control the total number of avatars not shown, you can use the total prop.

Eren Yeager
Mikasa Ackerman
Armin
Naruto
+20

Custom surplus

Set the renderSurplus prop as a callback to customize the surplus avatar. The callback will receive the surplus number as an argument based on the children and the max prop, and should return a React.ReactNode.

The renderSurplus prop is useful when you need to render the surplus based on the data sent from the server.

Naruto
Eren Yeager
Mikasa Ackerman
Armin
+5K

Spacing

You can change the spacing between avatars using spacing prop. You can use one of the presets (‘lg’, ‘md’, ‘sm’).

Naruto
Eren Yeager
Mikasa Ackerman
Armin
Naruto
Eren Yeager
Mikasa Ackerman
Armin
Naruto
Eren Yeager
Mikasa Ackerman
Armin

Avatar with badge

Naruto
Levi Ackerman
1m
Eren Yeager
Naruto

Avatar API

API reference docs for the React Avatar component.

Props

NameTypeDefaultDescription
childrennode-Used to render icon or text elements inside the Avatar if src is not set. This can be an element, or just a string.
classNamestring-Override or extend the styles applied to the component
altstring-Used to provide an alt attribute for the rendered img element.
variant'circular' | 'square' | 'rounded''circular'The shape of the avatar.
size'lg' | 'md' | 'sm''md'The size of the avatar.
outlinedboolfalseIf true, the outline will be applied.
srcstring-The src attribute for the img element.
imgPropsobject-Attributes applied to the img element if the component is used to display an image. it can be used to listen for loading error event.

AvatarGroup API

API reference docs for the React AvatarGroup component.

Props

NameTypeDefaultDescription
childrennode-The avatars to stack.
classNamestring-Override or extend the styles applied to the component
maxnumber5Max avatars to show before +x.
totalnumberchildren.lengthThe total number of avatars. Used for calculating the number of extra avatars.
renderSurplusfunc-custom renderer of extraAvatars
Signature: function(surplus: number) => React.ReactNode
surplus: number of extra avatars
Returns: custom element to display.
spacing'lg' | 'md' | 'sm'mdSpacing between avatars.
variant'circular' | 'square' | 'rounded'-The shape of the all avatars.
size'lg' | 'md' | 'sm'-The size of the all the avatars.
outlinedbooltrueIf true, the outline will be applied to all the avatars.
Last updated on