Avatar

Avatar Stack

A stack of participants with an honest width: the overlap is negative margin, and the tail folds into a counter.

  • avatar
  • group
  • stack
  • team

Preview

1440pxHost theme

Use it with AI

  1. 1. Copy the link.
  2. 2. Write to your agent in your own words and drop the link into the sentence.
  3. 3. The agent opens the link and installs the component from the registry.

put this in the header: https://vibeui.ru/c/avatar-003?lang=en

Show the full instructions

What the link says, spelled out. Use it when your agent cannot open links — paste this text instead.

# Install and place "avatar-003" (Avatar Stack) from VibeUI

## 1. Install first — do not skip, do not recreate
Run this exact command before writing any code:
npx shadcn@latest add https://vibeui.ru/r/avatar-003.json

Registry item: https://vibeui.ru/r/avatar-003.json
Installs to: components/vibeui/avatar-003.tsx (the exact path follows this project's components.json aliases).
npm dependencies: none.
Registry dependencies: none.

Install it from the registry. Do not recreate it from the description,
do not substitute a similar component from another library, and do not
rewrite it to match the project's existing style.

## 2. What it is
A stack of participants with an honest width: the overlap is negative margin, and the tail folds into a counter.

An overlapping avatar stack with a counter for the rest: the width stays true, the layering reads left to right, and the full name list goes into aria-label. Zero dependencies, one file, no client JS.

## 3. How to use it
import { Avatar003 } from "@/components/vibeui/avatar-003"

<Avatar003 names={["Anna Petrova", "Mark Ilyin"]} visible={4} />

Read the installed file for the full prop list.

## 4. Where to place it
This is a small inline component. Put it exactly where the user asked,
inside the existing markup. Do not create a new page, section or
wrapper for it. If a similar control already sits in that spot,
replace it instead of adding a second one.

Placement: ___
(The user fills this line in. If it is still blank, ask where to put it
instead of guessing.)

## 5. Keep exactly as installed
- the local --vibeui-avatar-003-* palette — do not swap it for your theme tokens
- the overlap via negative margin rather than absolute positioning: otherwise the stack's width lies
- the reversed z-index: without it the stack reads right to left
- the ring in the surface colour — a dense stack loses its edges without it
- aria-label with every name and aria-hidden on the circles: a "+3" says nothing
- the counter instead of an endless row

## 6. You may change
- the names array and the visible count
- size — sm, md or lg
- the overlap amount through the variable
- the group label through the label prop

## 7. Rules
- Beyond five visible avatars the layering stops: z-index is written for five positions.
- Initials stand in for photos here: if you have images, put an <img> inside the circle — the CSS is ready.
- The stack is not clickable: links and hover cards belong to the caller.
- Do not lift the CSS variables into globals.css: the component has to stay a single file.

## 8. Verify
- it renders with no console errors;
- it looks like the preview on the VibeUI page you copied this from;
- if it does not, you changed something listed in section 5 — put it back.

For developers

npx shadcn@latest add https://vibeui.ru/r/avatar-003.json
https://vibeui.ru/r/avatar-003.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-avatar-003-*. Серверный: хуков нет. Перекрытие задано отрицательным margin-left, поэтому ширина стопки настоящая и её можно поставить в строку. Порядок наложения задан z-index по nth-child: первый аватар лежит поверх второго. Весь список имён отдан скринридеру через aria-label на группе, сами кружки помечены aria-hidden.

Component source

The same file your agent installs. Here in case you would rather copy it by hand.

import type { ComponentPropsWithoutRef, CSSProperties } from "react"

export type Avatar003Props = Omit<
  ComponentPropsWithoutRef<"span">,
  "children"
> & {
  names?: string[]
  visible?: number
  size?: "sm" | "md" | "lg"
  label?: string
}

// Идея компонента: стопка участников. Перекрытие идёт отрицательным margin, а
// не позиционированием, поэтому ширина стопки честная и её можно поставить в
// строку текста. Порядок наложения обратный — первый аватар лежит поверх
// остальных, иначе стопка читается справа налево.
const STYLES = `
:where([data-vibeui-block="avatar-003"]){
--vibeui-avatar-003-size:2.25rem;
--vibeui-avatar-003-overlap:0.75rem;
--vibeui-avatar-003-ring:oklch(1 0 0);
--vibeui-avatar-003-more-bg:oklch(0.94 0.006 265);
--vibeui-avatar-003-more-fg:oklch(0.38 0.014 265);
--vibeui-avatar-003-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="avatar-003"]{
display:inline-flex;align-items:center;vertical-align:middle;
font-family:var(--vibeui-avatar-003-font);
}
[data-vibeui-block="avatar-003"][data-size="sm"]{--vibeui-avatar-003-size:1.75rem;--vibeui-avatar-003-overlap:0.625rem}
[data-vibeui-block="avatar-003"][data-size="lg"]{--vibeui-avatar-003-size:3rem;--vibeui-avatar-003-overlap:1rem}
[data-vibeui-block="avatar-003"] [data-part="item"]{
display:flex;align-items:center;justify-content:center;flex:none;
width:var(--vibeui-avatar-003-size);height:var(--vibeui-avatar-003-size);
border-radius:9999px;box-shadow:0 0 0 2px var(--vibeui-avatar-003-ring);
background:oklch(0.92 0.05 var(--vibeui-avatar-003-hue,250));
color:oklch(0.38 0.09 var(--vibeui-avatar-003-hue,250));
font-size:calc(var(--vibeui-avatar-003-size) * 0.34);font-weight:650;line-height:1;
user-select:none;
}
/* Перекрытие отрицательным margin: ширина стопки остаётся настоящей. */
[data-vibeui-block="avatar-003"] [data-part="item"] + [data-part="item"],
[data-vibeui-block="avatar-003"] [data-part="more"]{margin-left:calc(var(--vibeui-avatar-003-overlap) * -1)}
/* Первый аватар поверх второго, второй поверх третьего — стопка читается
   слева направо, как текст. */
[data-vibeui-block="avatar-003"] [data-part="item"]:nth-child(1){z-index:5}
[data-vibeui-block="avatar-003"] [data-part="item"]:nth-child(2){z-index:4}
[data-vibeui-block="avatar-003"] [data-part="item"]:nth-child(3){z-index:3}
[data-vibeui-block="avatar-003"] [data-part="item"]:nth-child(4){z-index:2}
[data-vibeui-block="avatar-003"] [data-part="item"]:nth-child(5){z-index:1}
[data-vibeui-block="avatar-003"] [data-part="more"]{
display:flex;align-items:center;justify-content:center;flex:none;
width:var(--vibeui-avatar-003-size);height:var(--vibeui-avatar-003-size);
border-radius:9999px;box-shadow:0 0 0 2px var(--vibeui-avatar-003-ring);
background:var(--vibeui-avatar-003-more-bg);color:var(--vibeui-avatar-003-more-fg);
font-size:calc(var(--vibeui-avatar-003-size) * 0.3);font-weight:650;line-height:1;
font-variant-numeric:tabular-nums;
}
[data-vibeui-block="avatar-003"] [data-part="label"]{
position:absolute;width:1px;height:1px;overflow:hidden;
clip-path:inset(50%);white-space:nowrap;
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="avatar-003"] *{animation:none!important;transition:none!important}}
`

const DEFAULT_NAMES = [
  "Анна Петрова",
  "Марк Ильин",
  "Мария Гурова",
  "Олег Дроздов",
  "Ирина Ким",
  "Пётр Волков",
]

// Оттенок из имени: FNV-1a, разложенный по двенадцати ступеням круга.
// Сумма кодов символов не годится — кириллические имена ложатся в один
// розовый сектор; ступени в 30° дают заведомо различимые цвета.
function hue(name: string) {
  let hash = 2166136261

  for (const symbol of name) {
    hash ^= symbol.codePointAt(0)!
    hash = Math.imul(hash, 16777619)
  }

  return ((hash >>> 0) % 12) * 30
}

function initials(name: string) {
  return name
    .split(" ")
    .slice(0, 2)
    .map((part) => part[0]?.toUpperCase() ?? "")
    .join("")
}

/**
 * Стопка участников с честной шириной и счётчиком остальных.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Avatar003({
  names = DEFAULT_NAMES,
  visible = 4,
  size = "md",
  label = "Участники",
  className,
  style,
  ...props
}: Avatar003Props) {
  const shown = names.slice(0, Math.max(1, Math.min(5, visible)))
  const rest = names.length - shown.length

  return (
    <>
      <style href="vibeui-avatar-003" precedence="medium">
        {STYLES}
      </style>
      <span
        {...props}
        data-vibeui-block="avatar-003"
        data-size={size}
        className={className}
        style={style as CSSProperties}
        role="group"
        aria-label={`${label}: ${names.join(", ")}`}
      >
        {shown.map((name) => (
          <span
            key={name}
            data-part="item"
            aria-hidden="true"
            style={{ "--vibeui-avatar-003-hue": hue(name) } as CSSProperties}
          >
            {initials(name)}
          </span>
        ))}
        {rest > 0 ? (
          <span data-part="more" aria-hidden="true">
            +{rest}
          </span>
        ) : null}
      </span>
    </>
  )
}