ComponentsData display

Avatar

Pictures for people and workspaces. Shows initials when there is no image or the image fails. Built with Base UI.

Installation

pnpm dlx shadcn@latest add https://sprout.tulipfarm.ai/r/avatar.json

Copies Avatar into your app, installs the packages, and adds the styles. Then import it from @/components/ui/avatar. Needs Tailwind CSS 4 and a components.json from shadcn init.

AM

Image status: idle

Usage

Avatar usageTSX
import {
  Avatar, AvatarImage, AvatarFallback, AvatarBadge,
} from "@tulipfarm/sprout/avatar";

<Avatar size="lg">
  <AvatarImage src={user.image} alt={user.name} />
  <AvatarFallback>AM</AvatarFallback>
  <AvatarBadge role="img" aria-label="Verified">
    <CheckIcon aria-hidden="true" />
  </AvatarBadge>
</Avatar>

Avatar takes size: "sm" (24px), "md" (32px, the default), or "lg" (40px). The fallback shows while the image loads, when it fails, and when there is no image. Usedelay on AvatarFallback to avoid a flash on fast networks. The image fades in over 180ms; reduced motion turns this off.

Sizes, images, fallbacks, and badges
AMAMsm
AMAMmd
AMAMlg
Avatar groups
ARS
+4
sm
ARS
+4
md
ARS
+4
lg
MR
+3
entity
AR
icon count

AvatarBadge sits on the bottom edge. Its icon hides at small sizes.AvatarGroup overlaps avatars, including EntityAvatar, and AvatarGroupCount matches their size. Set --sprout-avatar-ring to the surface color behind a group or badge.

Agent avatars

For agents, use AgentAvatar. It picks built-in artwork from the agent's id.

Entity avatars

Entity avatarTSX
<EntityAvatar
  seed={workspace.id}
  name={workspace.name}
  image={workspace.icon}
  size="sm"
  shape="square"
/>

EntityAvatar takes a seed, name, optional image, size ("sm", "md", or "lg"), and shape ("circle" or "square"). Without an image it shows the first letter on a gradient. The same seed always gives the same gradient. An empty name shows ?.

Entity shapes and sizes
Mcircle · sm
Mcircle · md
Mcircle · lg
Msquare · sm
Msquare · md
Msquare · lg
Gimage
Gsquare image
Rbroken image
?empty name
People use circles. Workspaces use squares. Without an image, the seed picks a stable gradient.
Image picker

Member photo

R

Workspace icon

S
Read-only settings row
Workspace iconG
Member table
  • AAlex Meadow
  • RRobin Field
  • SSam Orchard
  • MMember (not loaded)
Invite canvas labels
Workspace and account menus

In conversations

Message author
AM

Alex Meadow · 10:30

Can you help plan the garden?

Mention options
AAlex MeadowFictional team member
RRobin FieldFictional team member

Image upload, file checks, menus, tables, and messages above are sample code. The package only draws the avatar. Your application owns data, uploads, and navigation.

Accessibility

Give AvatarImage real alt text when the avatar is the only name on screen. Use alt="" when a name is next to it. Avatars are not focusable; put them inside a link or button for actions. Give badges and icon counts an accessible label.