Avatar

A person's photo, or their initials on a gradient disc. Staff take the navy info gradient and contacts a lighter slate, so the firm's people and its clients never look alike. Built on ui-sdk's Avatar: the image shows once it loads and the fallback covers a missing or broken photo.

BetaReady to use. Its API can still change in a minor release; the changelog says when.

import { Avatar, AvatarGroup } from "@leap-crm/design-system";

Playground

Change a prop and the component follows. Its code is under Props.

Avatar

Props

size
person
variant
weight
mask
ring
bordered
name
initials

AvatarGroup

Props

size
person
ring
max

Best practices

When to use it, and the rules that apply in particular places.

GuidancePractice
DoSet person to staff for the firm's lawyers and contact for clients and other parties, so the two never look alike in a list of matter people.
DoPass name on every avatar that stands for someone. It is the photo's alt text and the only name a screen reader hears.
DoSet mask on a client's avatar, so their initials stay out of session replay.
DoUse AvatarGroup for the staff on a matter or opportunity. Past max the rest collapse into a +N disc, and hover or focus lists everyone by name.
Don'tShow an empty owner slot with a staff or contact avatar. Use person="unassigned", which takes no colour, so an empty slot never reads as a person.
Don'tLower the opacity of a whole row to show an inactive person. Fade the avatar and set the name to the muted text colour, so the text stays readable.

Props

Avatar

PropTypeDefaultDescription
imagestring | null—Photo URL. The initials or fallback show until it loads, and if it fails.
initialsstring | null—Up to two letters, shown when there's no image or it fails. From the name when left out.
namestring—Who it is. The image's alt text, and the avatar's name for screen readers.
size"xxs" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl""xl"xxs 16 to 2xl 64: the disc and its initials together.
person"staff" | "contact" | "unassigned""contact"Staff (the firm's people), a contact (clients and other parties), or unassigned: a colourless face for no one, with a person icon as its fallback.
variant"default" | "tooltip""default"Tooltip inverts the fallback for the dark tooltip surface.
weight"book" | "semibold""book"Initials weight. Book (450) by default; semibold for small dense labels.
fallbackReactNode—Replaces the initials, like an icon for an unassigned row, an organisation or an agent.
maskbooleanfalseClient PII: masks the initials from session replay.
ringbooleanfalseA 2 px ring in the surface colour, to separate stacked avatars.
borderedbooleanfalseA hairline border, so a pale fallback matches a photo's edge.
classNamestring—Classes added to the root element, merged with its own. Tokens only.
fallbackClassNamestring—Classes for the initials or icon fallback, like a different tint.

AvatarGroup

PropTypeDefaultDescription
items *AvatarItem[]—The people, first on top. Past max, the rest collapse into a +N disc.
maxnumber4How many faces show before the rest collapse into a +N disc.
size"xxs" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl""sm"The size of every face, xxs 16 to 2xl 64.
person"staff" | "contact" | "unassigned""staff"Staff or contacts, for every face without its own.
classNamestring—Classes added to the root element, merged with its own. Tokens only.
tooltipTitlestring—A heading over the tooltip's list of names.
tooltipSectionsAvatarTooltipSection[]—Replaces the tooltip's single titled list; empty sections are left out.
tooltipSideSimpleTooltipProps["side"]"bottom"Which side the list of names opens on.
tooltipAlignSimpleTooltipProps["align"]"end"How the list of names lines up along that side.
tooltipFallbackClassNamestring—Classes for each name's fallback in the tooltip list.
disableTooltipbooleanfalseLeaves out the list of names, for a group that's already labelled beside it.
fallbackClassNamestring—Classes for every face's fallback.
avatarClassNamestring—Classes for every face.
ringbooleantrueThe separating ring and a hairline edge. On by default.

Code

What the playground shows, ready to copy.

Avatar

import { Avatar } from "@leap-crm/design-system";

<Avatar name="Jane Citizen" initials="JC" />

AvatarGroup

import { AvatarGroup } from "@leap-crm/design-system";

<AvatarGroup items={staff} />

Fallback icons

fallback replaces the initials: a person with no name yet, an organisation, an agent.

On a tooltip

variant="tooltip" inverts the fallback for the dark tooltip surface.

Ada Hartley

What the examples share

The imports and the scaffolding the examples above call. The scaffolding lives in this page, not in the library.

import { Bot, Building2, User } from "lucide-react";

import { Fragment } from "react";

import { Avatar, AvatarGroup } from "@leap-crm/design-system";

const sizes = ["xxs", "xs", "sm", "md", "lg", "xl", "2xl"] as const;

const photo = `data:image/svg+xml,${encodeURIComponent(
  '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><defs><linearGradient id="g" x2="1" y2="1"><stop offset="0" stop-color="#5b7099"/><stop offset="1" stop-color="#3e5480"/></linearGradient></defs><rect width="64" height="64" fill="url(#g)"/><circle cx="32" cy="25" r="9" fill="#ccdfee"/><path d="M17 49c1.5-8 7.5-12.5 15-12.5S45.5 41 47 49a3.5 3.5 0 0 1-3.5 4h-23A3.5 3.5 0 0 1 17 49z" fill="#ccdfee"/></svg>',
)}`;

const team = [
  { id: "1", name: "Ada Hartley", initials: "AH", role: "Responsible" },
  { id: "2", name: "Ben Okafor", initials: "BO", role: "Acting" },
  {
    id: "3",
    name: "Chloe Ng",
    initials: "CN",
    image: photo,
    role: "Assisting",
  },
  { id: "4", name: "Dev Patel", initials: "DP" },
  { id: "5", name: "Eve Moreau", initials: "EM" },
  { id: "6", name: "Finn Walsh", initials: "FW" },
];

function SizeGrid({ person }: { person: "staff" | "contact" }) {
  return (
    <div className="grid grid-cols-[auto_repeat(7,auto)] items-center justify-start gap-x-5 gap-y-4">
      <span />
      {sizes.map(size => (
        <span key={size} className="text-small text-neutral-text-muted">
          {size}
        </span>
      ))}
      {(["Initials", "Icon", "Image"] as const).map(type => (
        <Fragment key={type}>
          <span className="text-small text-neutral-text-muted">{type}</span>
          {sizes.map(size => (
            <Avatar
              key={`${type}-${size}`}
              size={size}
              person={person}
              name="Jane Citizen"
              initials="JC"
              image={type === "Image" ? photo : undefined}
              fallback={type === "Icon" ? <User /> : undefined}
            />
          ))}
        </Fragment>
      ))}
    </div>
  );
}