Avatar
Group Mosaic
A group chat avatar: up to four faces tiled inside one circle, with the tiling changing to match their number.
- avatar
- group
- chat
- mosaic
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-023?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-023" (Group Mosaic) 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-023.json
Registry item: https://vibeui.ru/r/avatar-023.json
Installs to: components/vibeui/avatar-023.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 group chat avatar: up to four faces tiled inside one circle, with the tiling changing to match their number.
A group chat avatar: up to four faces tiled inside one circle, the layout follows their number and the rest fold into a counter. Zero dependencies, one file, no client JS.
## 3. How to use it
import { Avatar023 } from "@/components/vibeui/avatar-023"
<Avatar023
names={["Anna Rebrova", "Ilya Mokhov", "Kim Son", "Pyotr Gai"]}
label="Catalog team"
/>
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-023-* palette — do not swap it for your theme tokens
- switching the layout through data-count: three faces in a square leave an empty cell
- the mosaic instead of an overlapping stack — a conversation row has no width for a stack
- the counter instead of a fifth face: a quarter-circle tile is already unreadable
- the full name list in the text beside it, not in a hover tooltip
- the card's own light surface: without it the dark text disappears on a dark background
## 6. You may change
- the names array and the label
- the circle size through size — sm, md or lg
- the colour of the gap between tiles
- the threshold at which faces fold into the counter
## 7. Rules
- Name order matters: the mosaic takes the first entries, so sort the array in the caller.
- Initials stand in for photos here: if you have images, put an <img> in the tile — the CSS is ready.
- The list key is the name: pass an id and change the key when full namesakes are possible.
- 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-023.jsonhttps://vibeui.ru/r/avatar-023.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-avatar-023-*. Серверный: хуков нет. Мозаика — grid 2×2 внутри круглой обёртки с overflow: hidden; раскладка переключается атрибутом data-count, потому что при трёх лицах в квадрате остаётся пустая клетка — первое лицо тогда занимает целую колонку. Зазор между клетками нарисован цветом карточки, а не border, чтобы не съедать полезную площадь. Пятый участник и дальше сворачиваются в счётчик, а полный список имён вынесен в текст рядом: клетки нечитаемы.
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 Avatar023Props = Omit<
ComponentPropsWithoutRef<"div">,
"children"
> & {
names?: string[]
label?: string
size?: "sm" | "md" | "lg"
}
// Идея компонента: аватар группового чата — четыре лица внутри одного круга.
// Стопка с перекрытием занимает ширину, которой в строке диалога нет, поэтому
// участники сложены в мозаику: круг остаётся круглым, а раскладка мозаики
// меняется от числа лиц (одно, два, три, четыре) — иначе при трёх участниках
// в углу висела бы пустая клетка. Пятый и дальше сворачиваются в счётчик.
const STYLES = `
:where([data-vibeui-block="avatar-023"]){
--vibeui-avatar-023-size:3rem;
--vibeui-avatar-023-bg:oklch(1 0 0);
--vibeui-avatar-023-fg:oklch(0.24 0.014 265);
--vibeui-avatar-023-muted:oklch(0.55 0.014 265);
--vibeui-avatar-023-border:oklch(0.91 0.006 265);
--vibeui-avatar-023-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
/* Своя светлая подложка: тёмный текст обязан читаться на любом фоне. */
[data-vibeui-block="avatar-023"]{
display:flex;align-items:center;gap:0.625rem;
box-sizing:border-box;width:100%;max-width:18rem;padding:0.5rem 0.75rem;
background:var(--vibeui-avatar-023-bg);
border:1px solid var(--vibeui-avatar-023-border);border-radius:0.75rem;
font-family:var(--vibeui-avatar-023-font);color:var(--vibeui-avatar-023-fg);
}
[data-vibeui-block="avatar-023"] *{box-sizing:border-box}
/* Мозаика в круге: клетки режутся overflow, зазор — цвет карточки. */
[data-vibeui-block="avatar-023"] [data-part="mosaic"]{
display:grid;flex:none;overflow:hidden;
grid-template-columns:1fr 1fr;grid-template-rows:1fr 1fr;
gap:0.0625rem;background:var(--vibeui-avatar-023-bg);
width:var(--vibeui-avatar-023-size);height:var(--vibeui-avatar-023-size);
border-radius:9999px;
}
[data-vibeui-block="avatar-023"][data-count="1"] [data-part="mosaic"]{grid-template-columns:1fr;grid-template-rows:1fr}
[data-vibeui-block="avatar-023"][data-count="2"] [data-part="mosaic"]{grid-template-rows:1fr}
/* Три лица: первое занимает целую колонку, пустой клетки не остаётся. */
[data-vibeui-block="avatar-023"][data-count="3"] [data-part="tile"]:first-child{grid-row:span 2}
[data-vibeui-block="avatar-023"] [data-part="tile"]{
display:grid;place-items:center;min-width:0;
background:oklch(0.9 0.06 var(--vibeui-avatar-023-tile,265));
color:oklch(0.36 0.12 var(--vibeui-avatar-023-tile,265));
font-size:calc(var(--vibeui-avatar-023-size) * 0.2);font-weight:700;line-height:1;
}
[data-vibeui-block="avatar-023"][data-count="1"] [data-part="tile"]{font-size:calc(var(--vibeui-avatar-023-size) * 0.34)}
[data-vibeui-block="avatar-023"] [data-rest="true"]{
background:oklch(0.93 0.008 265);color:oklch(0.42 0.014 265);
font-size:calc(var(--vibeui-avatar-023-size) * 0.18);
}
[data-vibeui-block="avatar-023"] [data-part="text"]{display:flex;flex-direction:column;gap:0.0625rem;min-width:0}
[data-vibeui-block="avatar-023"] [data-part="label"]{
font-size:0.875rem;font-weight:650;
overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
[data-vibeui-block="avatar-023"] [data-part="count"]{
font-size:0.75rem;color:var(--vibeui-avatar-023-muted);
overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
[data-vibeui-block="avatar-023"][data-size="sm"]{--vibeui-avatar-023-size:2.25rem}
[data-vibeui-block="avatar-023"][data-size="lg"]{--vibeui-avatar-023-size:4rem}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="avatar-023"] *{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 Avatar023({
names = ["Анна Реброва", "Илья Мохов", "Ким Сон", "Пётр Гай", "Мария Лоза"],
label = "Команда каталога",
size = "md",
className,
style,
...props
}: Avatar023Props) {
const rest = names.length - 4
const shown = rest > 0 ? names.slice(0, 3) : names.slice(0, 4)
return (
<>
<style href="vibeui-avatar-023" precedence="medium">
{STYLES}
</style>
<div
{...props}
data-vibeui-block="avatar-023"
data-count={rest > 0 ? 4 : shown.length}
data-size={size}
className={className}
style={style}
>
<span data-part="mosaic" aria-hidden="true">
{shown.map((person) => (
<span
key={person}
data-part="tile"
style={
{
"--vibeui-avatar-023-tile": hue(person),
} as CSSProperties
}
>
{initials(person)}
</span>
))}
{rest > 0 ? (
<span data-part="tile" data-rest="true">
+{rest + 1}
</span>
) : null}
</span>
<span data-part="text">
<span data-part="label">{label}</span>
{/* Имена целиком — здесь, а не в мозаике: клетки нечитаемы. */}
<span data-part="count">
Участников {names.length}: {names.join(", ")}
</span>
</span>
</div>
</>
)
}