Avatar
Dual Badge Avatar
An avatar carrying two badges at once: presence as a circle bottom-right, role as a lettered square top-left — different corner and different shape keep the meanings apart.
- avatar
- badge
- presence
- role
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-027?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-027" (Dual Badge Avatar) 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-027.json
Registry item: https://vibeui.ru/r/avatar-027.json
Installs to: components/vibeui/avatar-027.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
An avatar carrying two badges at once: presence as a circle bottom-right, role as a lettered square top-left — different corner and different shape keep the meanings apart.
An avatar with two badges: a round presence dot bottom-right and a lettered role square top-left. Both gaps are cut with nested masks. Zero dependencies, one file, no client JS.
## 3. How to use it
import { Avatar027 } from "@/components/vibeui/avatar-027"
<Avatar027 name="Maria Loza" status="online" role="owner" />
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-027-* palette — do not swap it for your theme tokens
- the nested masks instead of mask-composite: intersect — its support is still uneven
- the different corners: two badges in one corner read as a single compound mark
- the different shapes — a circle for presence, a square for role: colour cannot separate them
- the letter inside the role badge: colour must not be the only cue
- both meanings in words in the hidden caption — a dot and a letter are mute on their own
## 6. You may change
- presence through status — online, away or offline
- the role through role — owner, editor or reader
- the size through size — sm, md or lg
- role letters and badge colours in the dictionaries and variables
## 7. Rules
- A third badge does not fit: there are no free corners left, move the meaning into a line beside it.
- Role letters are language-bound: translate the dictionary, not just the caption.
- The role badge covers the top-left of the portrait: for photos with a face near the edge use size lg.
- 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-027.jsonhttps://vibeui.ru/r/avatar-027.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-avatar-027-*. Серверный: хуков нет. Оба зазора вырезаны масками, но не одной: маска роли висит на обёртке [data-part="cut"], маска точки — на самом портрете. Вложение даёт две дырки без mask-composite: intersect, поддержка которого до сих пор неровная. Значки нарочно разведены по углам и по форме — круг против квадрата, — а оба смысла названы словами в скрытой подписи.
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 Avatar027Props = Omit<
ComponentPropsWithoutRef<"span">,
"children"
> & {
name?: string
status?: "online" | "away" | "offline"
role?: "owner" | "editor" | "reader"
size?: "sm" | "md" | "lg"
}
// Идея компонента: два значка на одном аватаре, которые не спорят за смысл.
// Присутствие — круглая точка снизу справа, роль — квадрат с буквой сверху
// слева: разный угол и разная форма, поэтому «зелёный кружок» и «роль» не
// сливаются в одну догадку. Оба зазора вырезаны масками, но не одной: маска
// роли висит на обёртке, маска точки — на самом портрете, и вложение даёт две
// дырки без mask-composite, который поддержан не везде.
const STYLES = `
:where([data-vibeui-block="avatar-027"]){
--vibeui-avatar-027-size:2.75rem;
--vibeui-avatar-027-dot:0.75rem;
--vibeui-avatar-027-mark:1.0625rem;
--vibeui-avatar-027-online:oklch(0.62 0.15 152);
--vibeui-avatar-027-away:oklch(0.75 0.14 75);
--vibeui-avatar-027-offline:oklch(0.7 0.014 265);
--vibeui-avatar-027-role:oklch(0.55 0.2 262);
--vibeui-avatar-027-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="avatar-027"]{
position:relative;display:inline-flex;flex:none;
width:var(--vibeui-avatar-027-size);height:var(--vibeui-avatar-027-size);
font-family:var(--vibeui-avatar-027-font);
}
/* Вложенные маски: обёртка режет угол под роль, портрет — угол под точку. */
[data-vibeui-block="avatar-027"] [data-part="cut"]{
display:block;width:100%;height:100%;
mask-image:radial-gradient(circle calc(var(--vibeui-avatar-027-mark) * 0.78) at calc(var(--vibeui-avatar-027-mark) * 0.3) calc(var(--vibeui-avatar-027-mark) * 0.3),transparent 99%,#000 100%);
}
[data-vibeui-block="avatar-027"] [data-part="face"]{
display:flex;align-items:center;justify-content:center;
width:100%;height:100%;border-radius:9999px;
background:oklch(0.9 0.06 var(--vibeui-avatar-027-hue,265));
color:oklch(0.36 0.12 var(--vibeui-avatar-027-hue,265));
font-size:calc(var(--vibeui-avatar-027-size) * 0.34);font-weight:700;line-height:1;
mask-image:radial-gradient(circle calc(var(--vibeui-avatar-027-dot) * 0.72) at calc(100% - var(--vibeui-avatar-027-dot) * 0.42) calc(100% - var(--vibeui-avatar-027-dot) * 0.42),transparent 99%,#000 100%);
}
/* Присутствие: круг снизу справа. */
[data-vibeui-block="avatar-027"] [data-part="dot"]{
position:absolute;right:0;bottom:0;
width:var(--vibeui-avatar-027-dot);height:var(--vibeui-avatar-027-dot);
border-radius:9999px;background:var(--vibeui-avatar-027-offline);
}
[data-vibeui-block="avatar-027"][data-status="online"] [data-part="dot"]{background:var(--vibeui-avatar-027-online)}
[data-vibeui-block="avatar-027"][data-status="away"] [data-part="dot"]{
background:none;box-shadow:inset 0 0 0 3px var(--vibeui-avatar-027-away);
}
[data-vibeui-block="avatar-027"][data-status="offline"] [data-part="dot"]{
background:none;box-shadow:inset 0 0 0 2px var(--vibeui-avatar-027-offline);
}
/* Роль: квадрат с буквой сверху слева — другая форма и другой угол. */
[data-vibeui-block="avatar-027"] [data-part="mark"]{
position:absolute;left:0;top:0;
display:grid;place-items:center;
width:var(--vibeui-avatar-027-mark);height:var(--vibeui-avatar-027-mark);
border-radius:0.25rem;
background:var(--vibeui-avatar-027-role);color:oklch(1 0 0);
font-size:calc(var(--vibeui-avatar-027-mark) * 0.6);font-weight:700;line-height:1;
}
[data-vibeui-block="avatar-027"][data-role="editor"] [data-part="mark"]{background:oklch(0.6 0.13 195)}
[data-vibeui-block="avatar-027"][data-role="reader"] [data-part="mark"]{background:oklch(0.62 0.02 265)}
[data-vibeui-block="avatar-027"][data-size="sm"]{--vibeui-avatar-027-size:2.25rem;--vibeui-avatar-027-dot:0.625rem;--vibeui-avatar-027-mark:0.9375rem}
[data-vibeui-block="avatar-027"][data-size="lg"]{--vibeui-avatar-027-size:3.75rem;--vibeui-avatar-027-dot:0.9375rem;--vibeui-avatar-027-mark:1.375rem}
[data-vibeui-block="avatar-027"] [data-part="sr"]{
position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="avatar-027"] *{animation:none!important;transition:none!important}}
`
const STATUS_LABEL = {
online: "в сети",
away: "отошёл",
offline: "не в сети",
} as const
const ROLE_LABEL = {
owner: "владелец",
editor: "редактор",
reader: "читатель",
} as const
const ROLE_MARK = {
owner: "В",
editor: "Р",
reader: "Ч",
} as const
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 Avatar027({
name = "Мария Лоза",
status = "online",
role = "owner",
size = "md",
className,
style,
...props
}: Avatar027Props) {
const palette = {
"--vibeui-avatar-027-hue": hue(name),
...style,
} as CSSProperties
return (
<>
<style href="vibeui-avatar-027" precedence="medium">
{STYLES}
</style>
<span
{...props}
data-vibeui-block="avatar-027"
data-status={status}
data-role={role}
data-size={size}
className={className}
style={palette}
>
<span data-part="cut" aria-hidden="true">
<span data-part="face">{initials(name)}</span>
</span>
<span data-part="mark" aria-hidden="true">
{ROLE_MARK[role]}
</span>
<span data-part="dot" aria-hidden="true" />
{/* Оба значка названы словами: буква и точка сами по себе немые. */}
<span data-part="sr">
{name}, {ROLE_LABEL[role]}, {STATUS_LABEL[status]}
</span>
</span>
</>
)
}