All components

Avatar Stack

A compact, visually appealing component for displaying multiple user avatars in an overlapping stack. Perfect for showing participants in a group chat, team members, or active collaborators. Supports customizable size, max visible avatars, border styling, and optional '+n' indicator for overflow. Renders gracefully from 1 to dozens of users while maintaining a small footprint.

React
Figma
Open in New Tab

components/shadcncraft/pro-marketing/avatar-stack.tsx

import * as React from "react";

import { Avatar, AvatarFallback } from "@/components/ui/avatar";
import { cn } from "@/lib/utils";

interface AvatarStackProps extends React.ComponentProps<"div"> {
  orientation?: "horizontal" | "vertical";
  max?: number;
  size?: number;
  overlapRatio?: number;
  mask?: boolean;
}

export function AvatarStack({
  children,
  className,
  orientation = "horizontal",
  max, // Max visible avatars before "+N"
  size = 32, // Avatar size in pixels
  overlapRatio = 0.2, // 20% of avatar size
  mask = true,
  style,
  ...props
}: AvatarStackProps) {
  const avatarItems = React.Children.toArray(children).filter(
    (child): child is React.ReactElement<React.ComponentProps<typeof Avatar>> =>
      React.isValidElement(child) && child.type === Avatar
  );

  const avatarsCount = avatarItems.length;
  const showOverflow = max && avatarsCount > max;
  const overflowCount = showOverflow ? avatarsCount - max : 0;
  const visibleAvatars = showOverflow ? avatarItems.slice(0, max) : avatarItems;

  const avatarClassName = cn(
    "object-cover object-center",
    mask && "bg-background ring-2 ring-background"
  );

  return (
    <div
      data-slot="avatar-stack"
      data-orientation={orientation}
      data-size={size}
      data-overlap-ratio={overlapRatio}
      data-mask={mask}
      data-max={max}
      className={cn(
        "group flex items-center",
        "data-[orientation=horizontal]:flex-row data-[orientation=horizontal]:-space-x-[var(--overlap)]",
        "data-[orientation=vertical]:flex-col data-[orientation=vertical]:-space-y-[var(--overlap)]",
        className
      )}
      style={
        {
          ...style,
          "--overlap": `${overlapRatio * size}px`,
        } as React.CSSProperties
      }
      {...props}
    >
      {visibleAvatars.map((child, index) =>
        React.cloneElement(child, {
          key: index,
          className: cn(child.props.className, avatarClassName),
          style: { ...child.props.style, width: size, height: size },
        })
      )}

      {showOverflow && (
        <Avatar className={avatarClassName} style={{ width: size, height: size }}>
          <AvatarFallback className="text-xs font-medium text-muted-foreground">
            +{overflowCount}
          </AvatarFallback>
        </Avatar>
      )}
    </div>
  );
}
SBIOTJ

Join 3,000+ builders shipping with shadcncraft

Get access to this component and the full library

Production-ready blocks and components with matching Figma and React.

Get this componentFree
Benefits

Built for real interfaces

Each block is designed to work as part of a complete page, not just as a visual fragment.

Structured Layouts

Clear grids, consistent spacing, and predictable hierarchy.

Marketing + App Coverage

Landing pages, dashboards, onboarding, pricing, e-commerce, and more.

Theme Compatible

Works seamlessly with semantic tokens and theming.

Production-Ready States

Designed with real content, tokenized spacing, and real interaction patterns.

Figma + React Parity (Pro + React)

Design in Figma and ship with aligned React components.

Composable by Design

Mix blocks together to create complete pages without layout conflicts.

Frequently Asked Questions

Quick FAQs to get you started.
Still have questions? See all FAQs, or get support.

Yes. They follow shadcn/ui structure and are built for real products.

Real support from the team behind shadcncraft

Get help within 24 hours from the people who build and maintain the system.

Email
Prefer a direct line? Send us a message and we'll get back to you as soon as possible.
Discord
Get quick support, share feedback, or connect with other builders.
Feedback
Got something to say about anything shadcncraft? We'd love to hear it.