Skip to content
caliper ui docs

Components

Avatar

A person's photo, falling back to initials when there is no image.

Free
pnpm dlx shadcn@latest add @caliper/avatar

On call this week

Platform team · 19–25 Oct

  • Priya RamanAdmin · online
  • Rafael AbreuFinance · away
  • Kiara MurayamaOps · do not disturb
  • Tomás FerreiraEditor · offline
Installs components/ui/avatar.tsxDepends on none beyond ReactMotion none in component source

When to use

Use it for

  • Identifying people in lists, comments and menus.
  • Anywhere a name alone is too plain.

Skip it when

  • Decoration with no person behind it.

Installation

terminal
pnpm dlx shadcn@latest add @caliper/avatar

Adds its 2 files to components/ui/, each with its own stylesheet, and installs their packages. No account needed. The first part also adds Caliper UI’s tokens; import them once as in Installation.

Usage

This is the code behind the preview above. It is built from Avatar, AvatarPhotos and avatarTone.

example.tsx
import { type ReactNode } from "react"
import { Avatar } from "@/components/ui/avatar"
import { cn } from "@/components/ui/lib/cn"

function Panel({ title, context, media, action, className, children }: { title: string; context: string; media?: ReactNode; action?: ReactNode; className?: string; children?: ReactNode }) {
  return (
    <section className={cn("grid w-full max-w-md gap-5 rounded-overlay border border-border bg-background p-6 shadow-resting", className)}>
      <div className="flex items-center gap-3">
        {media}
        <div className="grid min-w-0 flex-1 gap-1">
          <p className="font-medium">{title}</p>
          <p className="text-sm text-muted-foreground">{context}</p>
        </div>
        {action}
      </div>
      {children}
    </section>
  );
}

export function PersonAvatars() {
  const people = [
    { name: "Priya Raman", role: "Admin · online", presence: "online" as const },
    { name: "Rafael Abreu", role: "Finance · away", presence: "away" as const },
    { name: "Kiara Murayama", role: "Ops · do not disturb", presence: "busy" as const },
    { name: "Tomás Ferreira", role: "Editor · offline", presence: "offline" as const },
  ];
  return (
    <Panel title="On call this week" context="Platform team · 19–25 Oct" className="max-w-sm">
      <ul className="grid gap-3">
        {people.map((person) => (
          <li key={person.name} className="flex items-center gap-3">
            <Avatar name={person.name} presence={person.presence} alt="" className="size-10" />
            <span className="grid">
              <span className="text-sm font-medium">{person.name}</span>
              <span className="text-xs text-muted-foreground">{person.role}</span>
            </span>
          </li>
        ))}
      </ul>
    </Panel>
  );
}

API reference

Avatar

component

Also accepts the native props of its root element and a ref.

PropTypeDefaultDescription
name *string—
srcstring—
altstringname
shape"circle" | "square""circle""square" for a company, workspace or integration: a coloured mark instead of a person's orb or photo.
presence"online" | "away" | "busy" | "offline"—Shown as a shape at the corner: filled, half, dash or ring.

AvatarPhotos

component

No props of its own; it accepts the native props of its root element.

avatarTone

component

No props of its own; it accepts the native props of its root element.

Accessibility

It is built on native elements and keeps aria-hidden and aria-label in step with state.

No custom key handling; Tab and the native activation keys do the work.

Motion

It declares no animation in its component source. Any transition comes from its stylesheet, which uses the duration tokens that collapse to instant under prefers-reduced-motion.

All Identity & navigation examples