BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/shadcncraft/avatar-stack

Avatar Stack

shadcncraft/avatar-stack
FreeComponent

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.

Live preview

live · rendered by the registry
Rendered by shadcncraft on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://shadcncraft.com/r/avatar-stack.json

Source

components/shadcncraft/pro-marketing/avatar-stack.tsxshadcncraft.com/r/avatar-stack.json
1import * as React from "react";
2
3import { cn } from "@/lib/utils";
4
5interface AvatarStackProps extends React.ComponentProps<"div"> {
6 orientation?: "horizontal" | "vertical";
7 max?: number;
8 avatarSize?: number;
9 overlapRatio?: number;
10 mask?: boolean;
11}
12
13export function AvatarStack({
14 children,
15 className,
16 orientation = "horizontal",
17 max, // Max visible avatars before "+N"
18 avatarSize, // Avatar size in pixels
19 overlapRatio = 0.2, // 20% of avatar size
20 mask = true,
21 style,
22 ...props
23}: AvatarStackProps) {
24 const items = React.Children.toArray(children);
25 const overflow = max ? Math.max(0, items.length - max) : 0;
26 const visible = items.slice(0, max);
27
28 // Use the first child as the chip wrapper so its size, shape, and styling
29 // (Avatar from any registry, plain div, etc.) automatically apply to "+N".
30 const firstChild = visible.find(React.isValidElement);
31
32 // `avatarSize` set: force children + chip to that pixel size; derive overlap from it.
33 // `avatarSize` omitted: children keep intrinsic size; overlap falls back to 0.5rem.
34 // Override the fallback overlap via `style={{ "--overlap": "..." }}` if needed.
35 const overlap = avatarSize != null ? `${overlapRatio * avatarSize}px` : "0.5rem";
36
37 return (
38 <div
39 data-slot="avatar-stack"
40 data-orientation={orientation}
41 className={cn(
42 "group isolate flex items-center",
43 "data-[orientation=horizontal]:flex-row data-[orientation=horizontal]:-space-x-(--overlap)",
44 "data-[orientation=vertical]:flex-col data-[orientation=vertical]:-space-y-(--overlap)",
45 "*:shrink-0 *:object-cover *:object-center",
46 avatarSize != null && "*:size-(--avatar-size)!",
47 mask && "*:ring-2 *:ring-background",
48 className
49 )}
50 style={
51 {
52 ...style,
53 "--overlap": overlap,
54 ...(avatarSize != null && { "--avatar-size": `${avatarSize}px` }),
55 } as React.CSSProperties
56 }
57 {...props}
58 >
59 {visible}
60 {overflow > 0 &&
61 firstChild &&
62 React.cloneElement(
63 firstChild as React.ReactElement<Record<string, unknown>>,
64 { key: "overflow", "data-slot": "avatar-stack-overflow" },
65 <span className="flex size-full items-center justify-center rounded-[inherit] bg-muted text-xs font-medium text-muted-foreground">
66 +{overflow}
67 </span>
68 )}
69 </div>
70 );
71}

Files it writes

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

Facts

Registry
shadcncraft
Type
registry:ui
Access
Free
Files written
1
Licence
the repository states none
First indexed
2026-08-03
Last confirmed
yesterday

Go to the source

Docs on shadcncraft shadcncraft.com Raw registry item This item as JSON

More from shadcncraft

All 26 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
BadgebadgeshadcncraftComponentsFreeno deps
Featured Iconfeatured-iconshadcncraftComponentsFreeno deps
Image Zoomimage-zoomshadcncraftComponentsFree1 dep
MarqueemarqueeshadcncraftComponentsFreeno deps
Page Headingpage-headingshadcncraftComponentsFreeno deps
Placeholder Logoplaceholder-logoshadcncraftComponentsFreeno deps
Profile Cardprofile-cardshadcncraftComponentsFreeno deps
Section Headingsection-headingshadcncraftComponentsFreeno deps
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex