@biem/ui

Avatar

An image that lets users recognize a person at a glance.

An avatar represents a person with a profile image. Its fallback stands in while the image loads and when it is missing, so users can always tell who is meant.

L

Usage

avatar-default.tsx
import {
	Avatar,
	AvatarFallback,
	AvatarImage,
} from "@biem/ui/components/ui/avatar";
import { generateGradient } from "@biem/ui/lib/generate-gradient";

const portrait = generateGradient("Name");

export function AvatarDefault() {
	return (
		<Avatar>
			<AvatarImage src={portrait} alt="Name"/>
			<AvatarFallback>L</AvatarFallback>
		</Avatar>
	);
}

Examples

Fallback

New employees and external contacts often have no profile image yet. Without an image, AvatarFallback takes its place right away, for example with the initials of the person, so users can still tell the people in a list apart.

F

Small

Table rows and activity feeds name a person beside every entry, such as the employee who booked a transfer. There, size set to "sm" lets the avatar accompany the entry without pushing the figures aside.

F

Default Size

Comments, approvals and assignments show the person behind a decision. Whenever no other size is set, an avatar takes the size "default", so people appear at the same scale across every product.

F

Large

A profile header or the detail view of an employee puts one person at the center. Here, size set to "lg" gives the avatar more presence, so users see at once whose data they are working with.

F

Badge

Whether a colleague is on shift or has approved a request often matters as much as who that colleague is. Through AvatarBadge the avatar carries a marker for such a status, so users take in the person and the state together.

F

Badge with Icon

A plain marker tells users that a status applies, but not which one. Placed inside the badge, an icon names it, so users can tell several states apart without a legend. Small avatars leave too little room for it, and the badge then shows the marker alone.

F

Group

Shifts, store visits and stock counts often involve several people at once. Gathered in an AvatarGroup, their avatars stay compact, so users see at a glance who shares the task.

OFL

Group Count

Some teams are larger than the room a group can offer. Closing the group, AvatarGroupCount states how many more people belong to it, so users grasp the size of the team without a face for every member.

OFL
+3

Group Count with Icon

Not every group needs an exact number, for example where a team changes in the course of the day. With an icon in place of the number, AvatarGroupCount signals that more people belong to the group without stating how many.

OFL

API Reference

Avatar

Propsize
Type"default" | "sm" | "lg"
Default"default"
DescriptionControls the dimensions of the avatar. The fallback text, the badge and the group count follow it.
Proprender
TypeReactElement | render function
Default–
DescriptionReplaces the native element or composes the avatar with another component.

AvatarImage

Propsrc
Typestring
Default–
DescriptionSets the URL of the image. The fallback shows while the image loads and when it fails to load.
Propalt
Typestring
Default–
DescriptionDescribes the image for users who can't see it.
ProponLoadingStatusChange
Type(status: "idle" | "loading" | "loaded" | "error") => void
Default–
DescriptionRuns when the loading status of the image changes.
PropkeepMounted
Typeboolean
Defaultfalse
DescriptionKeeps the image element in the DOM and loads the image there instead of preloading it. Set it for lazy loading or for an optimized image component such as next/image.
Proprender
TypeReactElement | render function
Default–
DescriptionReplaces the native element or composes the image with another component.

AvatarFallback

Propdelay
Typenumber
Default0
DescriptionSets how many milliseconds the fallback waits before it appears. An image that loads within this time replaces it before users see it.
Proprender
TypeReactElement | render function
Default–
DescriptionReplaces the native element or composes the fallback with another component.

AvatarBadge

AvatarBadge places a marker on the bottom right corner of the avatar. It renders a span and has no props of its own.

AvatarGroup

AvatarGroup stacks avatars so that they overlap. It renders a div and has no props of its own.

AvatarGroupCount

AvatarGroupCount ends a group with a count of further avatars or an icon. It renders a div and has no props of its own.