Components

Avatar

The shadcn/ui Avatar with a soft image fade-in, a hairline edge and an on-theme initials fallback — plus two animated React avatar blocks built with Motion and Radix: an overlapping avatar group that fans out on hover with a +N overflow chip, and a status avatar with a pulsing online, away or busy indicator.

  • Drop-in shadcn API
  • Radix Avatar
  • Motion blocks
  • prefers-reduced-motion

Installation

$ npx shadcn@latest add https://duskui.com/r/avatar.json

Replaces components/ui/avatar.tsx with the same exports and props. The fade-in is CSS (tw-animate-css, included with shadcn/ui), so the base needs no Motion.

Usage

user-avatar.tsx
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"

export function UserAvatar() {
  return (
    <Avatar>
      <AvatarImage src="https://i.pravatar.cc/150?img=47" alt="Maya Chen" />
      <AvatarFallback>MC</AvatarFallback>
    </Avatar>
  )
}

Examples

Default

Radix renders the image only once it has loaded, so it fades and settles in over the fallback instead of popping. A broken URL keeps the initials. Resize with size-* and change the shape with rounded-* on both the avatar and the fallback.

MCLPIDSODU

Blocks

Ready-made variations composed from the base component with Motion. Each installs on its own and pulls in its dependencies automatically.

Avatar Group

An overlapping stack that fans out symmetrically when you hover it. The avatar under the pointer lifts above its neighbours and shows a name tag, and anything past max collapses into a “+N” chip. It only moves with transforms, so nothing around it shifts.

$ npx shadcn@latest add https://duskui.com/r/avatar-group.json
PropTypeDefaultDescription
items{ name: string; src?: string; fallback?: ReactNode }[]—The people. name is used for the label, the name tag and the initials.
maxnumber4Avatars shown before the rest collapse into +N.
size"sm" | "default" | "lg""default"Avatar size and overlap.
spreadnumber—Extra pixels between avatars on hover. Defaults per size; 0 disables.
showNamesbooleantrueShow a name tag above the hovered avatar.
labelstring"People"Accessible name for the list.

Status Avatar

An avatar with a presence dot and a matching ring. Changing the status scales the new dot in and crossfades the ring; set pulse for a faint ring on live statuses (online, busy). Click the button to cycle through the statuses.

$ npx shadcn@latest add https://duskui.com/r/status-avatar.json
PropTypeDefaultDescription
namestring—Full name, for the label and the initials. Required.
srcstring—Image URL. Falls back to initials.
status"online" | "away" | "busy" | "offline""online"Presence state; sets the dot and ring color.
size"sm" | "default" | "lg""default"Avatar and dot size.
showRingbooleantrueDraw a ring in the status color.
pulsebooleanfalseAdd a faint pulse ring to the dot for online and busy.
fallbackReactNode—Replaces the initials.

API Reference

Same parts as shadcn/ui: Avatar, AvatarImage and AvatarFallback. Each forwards the Radix Avatar props.

PropTypeDefaultDescription
classNamestring—Size and shape, e.g. size-12 rounded-lg (on Avatar).
src / altstring—Image source and alternative text (on AvatarImage).
onLoadingStatusChange(status: "idle" | "loading" | "loaded" | "error") => void—Called as the image loads (on AvatarImage).
delayMsnumber—Wait before showing the fallback, to avoid a flash on fast connections (on AvatarFallback).

Accessibility

  • Always give AvatarImage an alt; when only initials show, add an aria-label or nearby text with the person's name.
  • Avatar Group is a labelled list; each avatar is role="img" with the person's name, and the overflow chip reads “N more”.
  • Status Avatar is labelled “Name (Status)”, so the presence state is never conveyed by color alone.
  • Under prefers-reduced-motion the image only fades, the group spreads instantly and the status pulse stops.