Avatar

A person's picture in a circle, 32px by default. AvatarImage shows the picture once it has loaded, and AvatarFallback shows the initials until then or when there is none.

U1U2
import { Avatar, AvatarFallback, AvatarImage } from "@produkto/ui/Avatar";

const Example = () => (
  <div className="flex flex-wrap items-center gap-2">
    <Avatar>
      <AvatarImage alt="User 1" src="https://picsum.photos/id/237/96/96" />
      <AvatarFallback>U1</AvatarFallback>
    </Avatar>
    <Avatar>
      <AvatarFallback>U2</AvatarFallback>
    </Avatar>
  </div>
);

export default Example;

Usage

import { Avatar, AvatarFallback, AvatarImage } from "@produkto/ui/Avatar";
<Avatar>
  <AvatarImage alt="User 1" src="/avatar.png" />
  <AvatarFallback>U1</AvatarFallback>
</Avatar>

Examples

Sizes

size sets the avatar at 20, 24, 32, 40 or 48 pixels: xs, sm, base (the default), lg or xl, and its initials, its badge and a group's count follow.

U1
U1
U1
U1
U1
import {
  Avatar,
  AvatarFallback,
  AvatarImage,
  type AvatarSize,
} from "@produkto/ui/Avatar";
import { Label } from "@produkto/ui/Label";

const sizes: { size: AvatarSize; label: string }[] = [
  { size: "xs", label: "Extra small" },
  { size: "sm", label: "Small" },
  { size: "base", label: "Base" },
  { size: "lg", label: "Large" },
  { size: "xl", label: "Extra large" },
];

const Example = () => (
  <div className="flex flex-wrap items-start gap-6">
    {sizes.map((item) => (
      <div className="flex flex-col items-center gap-2" key={item.size}>
        <Label>{item.label}</Label>
        <Avatar size={item.size}>
          <AvatarImage alt="User 1" src="https://picsum.photos/id/237/96/96" />
          <AvatarFallback>U1</AvatarFallback>
        </Avatar>
      </div>
    ))}
  </div>
);

export default Example;

Border radius

borderRadius sets its corners on the kit's one scale: none, xs 4px, sm 6px, base 8px, lg 12px, xl 16px or full, the default. A person keeps the circle, and a thing's picture, such as a product's or a team's, takes small corners, sm.

U1U1U1U1U1U1U1
import {
  Avatar,
  AvatarFallback,
  AvatarImage,
  type AvatarBorderRadius,
} from "@produkto/ui/Avatar";

const radii: AvatarBorderRadius[] = [
  "none",
  "xs",
  "sm",
  "base",
  "lg",
  "xl",
  "full",
];

const Example = () => (
  <div className="flex flex-wrap items-center gap-2">
    {radii.map((borderRadius) => (
      <Avatar key={borderRadius} borderRadius={borderRadius}>
        <AvatarImage alt="User 1" src="https://picsum.photos/id/237/96/96" />
        <AvatarFallback>U1</AvatarFallback>
      </Avatar>
    ))}
  </div>
);

export default Example;

With badge

AvatarBadge pins a dot to the avatar's bottom corner, such as a person's status, and an icon inside it is sized to the avatar and hidden on the small one.

U1U2
import {
  Avatar,
  AvatarBadge,
  AvatarFallback,
  AvatarImage,
} from "@produkto/ui/Avatar";
import { Add01Icon } from "@hugeicons/core-free-icons";
import { Icon } from "@produkto/ui/Icon";

const Example = () => (
  <div className="flex flex-wrap items-center gap-2">
    <Avatar>
      <AvatarImage alt="User 1" src="https://picsum.photos/id/237/96/96" />
      <AvatarFallback>U1</AvatarFallback>
      <AvatarBadge />
    </Avatar>
    <Avatar>
      <AvatarImage alt="User 2" src="https://picsum.photos/id/1062/96/96" />
      <AvatarFallback>U2</AvatarFallback>
      <AvatarBadge>
        <Icon icon={Add01Icon} strokeWidth={3} />
      </AvatarBadge>
    </Avatar>
  </div>
);

export default Example;

API Reference

Avatar

AvatarProps · components/Avatar/Avatar.types.ts
PropTypeDefault
sizeAvatarSize"xs" | "sm" | "base" | "lg" | "xl""base"
borderRadiusAvatarBorderRadius"none" | "xs" | "sm" | "base" | "lg" | "xl" | "full""full"

AvatarImage

AvatarImageProps · takes the props of Radix Avatar.Image

AvatarFallback

AvatarFallbackProps · takes the props of Radix Avatar.Fallback

AvatarBadge

AvatarBadgeProps · takes the props of <span>

AvatarGroup

AvatarGroupProps · takes the props of <div>

AvatarGroupCount

AvatarGroupCountProps · takes the props of <div>

It also takes the props of Radix Avatar.Root.