Updated
Avatar Stack
Customize
Max4
Size40px
Overlap12px
click
Installation
npx shadcn@latest add https://uibrik.com/r/avatar-stack.jsonInstall the packages
npm install @tabler/icons-react motionAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/avatar-stack/avatar-stack.tsx"use client"; import { useEffect, useId, useLayoutEffect, useRef, useState } from "react"; import { AnimatePresence, LayoutGroup, motion, useReducedMotion, type Transition } from "motion/react"; import { IconX } from "@tabler/icons-react"; import { cn } from "@/lib/utils"; // Avatar stack. A short row of overlapping avatars that fans out a little on // hover. Open it and the row itself reflows into a list: the container grows // into a card and every avatar springs from its place in the row to its place // in the list, names easing in beside them. It is one tree in both states, so // motion's layout animation carries each element across and nothing is // swapped or cross-faded. Only positions are layout-animated: the card's // surface tweens its real width, height and radius instead of being scaled, // so text and shadows never stretch on the way. // // Opening springs with a little life; closing settles faster and without // overshoot, so dismissing never feels slower than asking. // // The card is absolutely positioned over a placeholder the size of the row, // so opening it never shifts the page around it. const PAD = 8; // card padding, px; also how far the card sits out from the row const GAP = 8; // between rows, px
Adds the files to
components/uibrik/avatar-stack and installs @tabler/icons-react and motion. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/avatar-stack.Usage
import { AvatarStack } from "@/components/uibrik/avatar-stack/avatar-stack";const people = [ { id: 1, name: "Maya Chen", role: "Design lead", src: "/registry/avatar-stack/maya.svg" }, { id: 2, name: "Jonas Weber", role: "Engineering", src: "/registry/avatar-stack/jonas.svg" }, // …4 more];<AvatarStack people={people} max={4} size={40} overlap={12} trigger="click"/>Where to use Avatar Stack
Document collaborators
Overlapping faces show who is on a file in little space, and fan out on hover to name each person.
Pairs with Live Cursors
Team rows in lists
A compact stack fits inside a project or table row, and the card that grows out of it lists everyone.
Pairs with Data Table
Social proof
A row of real faces beside a sign-up form says that other people already use the product.
Pairs with Waitlist Input
Props
AvatarStack- max
- Type number
- 4
- Avatars shown in the row before the +N.
- size
- Type number
- 40
- Avatar diameter.
- overlap
- Type number
- 12
- How far each avatar tucks under the one before it.
- trigger
- Type "click" | "hover"
- "click"
- What opens the list.
- peoplerequired
- Type { id; name; role?; src? }[]
- –
- Avatars in order. Without a src the initials show.
- className
- Type string
- –
- Classes for the wrapper.