Avatar
Expanding Stack
A stack that spreads open to show everyone: the expansion hangs on hover and on focus alike, because a keyboard has no hover.
- avatar
- stack
- hover
- team
Preview
Use it with AI
- 1. Copy the link.
- 2. Write to your agent in your own words and drop the link into the sentence.
- 3. The agent opens the link and installs the component from the registry.
put this in the header: https://vibeui.ru/c/avatar-031?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-031" (Expanding 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-031.json
Registry item: https://vibeui.ru/r/avatar-031.json
Installs to: components/vibeui/avatar-031.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 that spreads open to show everyone: the expansion hangs on hover and on focus alike, because a keyboard has no hover.
An overlapping avatar row that spreads open on hover and on keyboard focus. Every face is its own button. Zero dependencies, one file, no client JS.
## 3. How to use it
import { Avatar031 } from "@/components/vibeui/avatar-031"
<Avatar031
names={["Anna Rebrova", "Ilya Mokhov", "Kim Son"]}
overlap={55}
size="md"
/>
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-031-* palette — do not swap it for your theme tokens
- expanding on both :hover and :focus-within — hover does not exist on a keyboard
- the overlap via negative margin rather than absolute positioning: otherwise the row's width lies
- the button around every face: in a dense stack a circle is half-covered and cannot be clicked
- the reversed z-index: without it the stack reads right to left
- the prefers-reduced-motion rule that removes the transition
## 6. You may change
- the names array
- the stack density through overlap — a percentage of the size
- the face size through size — sm, md or lg
- the circle ring colour for your surface
## 7. Rules
- An expanded stack is wider and pushes its neighbours: put it last in a row or budget the space.
- Layering is written for five positions: add nth-child rules for a longer row.
- Only the first five names show: trim the tail in the caller and offer a "show all" link.
- 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-031.jsonhttps://vibeui.ru/r/avatar-031.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-avatar-031-*. Серверный: хуков нет, раскрытие целиком на CSS. Перекрытие задано отрицательным margin в долях размера, поэтому одно число управляет и плотностью, и шириной строки, а раскрытие — это тот же margin, уезжающий в ноль с переходом. Раскрытие висит на :hover и на :focus-within: на клавиатуре наведения нет. Каждое лицо — отдельная кнопка с доступной подписью: закрытый наполовину кружок нажать нельзя.
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 Avatar031Props = Omit<
ComponentPropsWithoutRef<"ul">,
"children"
> & {
names?: string[]
overlap?: number
size?: "sm" | "md" | "lg"
}
// Идея компонента: стопка, которая раздвигается и показывает всех. Плотная
// стопка экономит место, но лица в ней наполовину закрыты и по ним не нажать;
// раздвигать её по наведению мало — на клавиатуре наведения нет, поэтому
// раскрытие висит и на :focus-within. Перекрытие задано отрицательным margin в
// долях размера, поэтому одно число управляет и плотностью, и шириной строки, а
// раскрытие — это просто margin, уезжающий в ноль.
const STYLES = `
:where([data-vibeui-block="avatar-031"]){
--vibeui-avatar-031-size:2.5rem;
--vibeui-avatar-031-overlap:55;
--vibeui-avatar-031-surface:oklch(1 0 0);
--vibeui-avatar-031-accent:oklch(0.55 0.2 262);
--vibeui-avatar-031-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="avatar-031"]{
display:flex;align-items:center;width:max-content;max-width:100%;
margin:0;padding:0;list-style:none;
font-family:var(--vibeui-avatar-031-font);
}
[data-vibeui-block="avatar-031"] *{box-sizing:border-box}
[data-vibeui-block="avatar-031"] [data-part="cell"]{
margin-left:calc(var(--vibeui-avatar-031-size) * var(--vibeui-avatar-031-overlap) / -100);
transition:margin-left .22s ease;
}
[data-vibeui-block="avatar-031"] [data-part="cell"]:first-child{margin-left:0}
/* Раскрытие и по наведению, и по фокусу: на клавиатуре наведения нет. */
[data-vibeui-block="avatar-031"]:hover [data-part="cell"],
[data-vibeui-block="avatar-031"]:focus-within [data-part="cell"]{
margin-left:0.1875rem;
}
[data-vibeui-block="avatar-031"]:hover [data-part="cell"]:first-child,
[data-vibeui-block="avatar-031"]:focus-within [data-part="cell"]:first-child{margin-left:0}
[data-vibeui-block="avatar-031"] [data-part="face"]{
display:grid;place-items:center;
appearance:none;cursor:pointer;padding:0;border:0;
width:var(--vibeui-avatar-031-size);height:var(--vibeui-avatar-031-size);
border-radius:9999px;
box-shadow:0 0 0 0.125rem var(--vibeui-avatar-031-surface);
background:oklch(0.9 0.06 var(--vibeui-avatar-031-hue,265));
color:oklch(0.36 0.12 var(--vibeui-avatar-031-hue,265));
font:inherit;font-size:calc(var(--vibeui-avatar-031-size) * 0.34);font-weight:700;line-height:1;
}
[data-vibeui-block="avatar-031"] [data-part="face"]:focus-visible{outline:2px solid var(--vibeui-avatar-031-accent);outline-offset:2px}
/* Порядок наложения слева направо: без него стопка читается наоборот. */
[data-vibeui-block="avatar-031"] [data-part="cell"]:nth-child(1){z-index:5}
[data-vibeui-block="avatar-031"] [data-part="cell"]:nth-child(2){z-index:4}
[data-vibeui-block="avatar-031"] [data-part="cell"]:nth-child(3){z-index:3}
[data-vibeui-block="avatar-031"] [data-part="cell"]:nth-child(4){z-index:2}
[data-vibeui-block="avatar-031"] [data-part="cell"]:nth-child(5){z-index:1}
[data-vibeui-block="avatar-031"] [data-part="cell"]{position:relative}
[data-vibeui-block="avatar-031"][data-size="sm"]{--vibeui-avatar-031-size:2rem}
[data-vibeui-block="avatar-031"][data-size="lg"]{--vibeui-avatar-031-size:3.25rem}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="avatar-031"] *{animation:none!important;transition:none!important}}
`
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.charAt(0).toUpperCase())
.join("")
}
/**
* Ряд аватаров, который раздвигается по наведению и по фокусу с клавиатуры.
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Avatar031({
names = ["Анна Реброва", "Илья Мохов", "Ким Сон", "Пётр Гай", "Мария Лоза"],
overlap = 55,
size = "md",
className,
style,
...props
}: Avatar031Props) {
const palette = {
"--vibeui-avatar-031-overlap": Math.min(80, Math.max(0, overlap)),
...style,
} as CSSProperties
return (
<>
<style href="vibeui-avatar-031" precedence="medium">
{STYLES}
</style>
<ul
{...props}
data-vibeui-block="avatar-031"
data-size={size}
className={className}
style={palette}
>
{names.slice(0, 5).map((person) => (
<li
key={person}
data-part="cell"
style={
{
"--vibeui-avatar-031-hue": hue(person),
} as CSSProperties
}
>
{/* Каждое лицо — своя цель: закрытый наполовину кружок не нажать. */}
<button type="button" data-part="face" aria-label={person}>
<span aria-hidden="true">{initials(person)}</span>
</button>
</li>
))}
</ul>
</>
)
}