Avatar
Badged Avatar
An avatar with a corner badge — verified, role or newcomer — cut out of the background by its own ring.
- avatar
- badge
- verified
- role
Preview
1440pxHost theme
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-005?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-005" (Badged 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-005.json
Registry item: https://vibeui.ru/r/avatar-005.json
Installs to: components/vibeui/avatar-005.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 with a corner badge — verified, role or newcomer — cut out of the background by its own ring.
An avatar with a corner badge: verified, admin or new. The badge is separated by a ring in the surface colour and spelled out in aria-label. Zero dependencies, one file, no client JS.
## 3. How to use it
import { Avatar005 } from "@/components/vibeui/avatar-005"
<Avatar005 name="Mark Ilyin" badge="verified" size="lg" />
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-005-* palette — do not swap it for your theme tokens
- the ring in the surface colour: on a dark photo the badge would otherwise merge into it
- spelling the badge out in aria-label — a tick alone says nothing
- switching the kind through data-badge instead of separate components
- the tick drawn with borders instead of an icon package
- the --vibeui-avatar-005-cut variable: it has to match the page background
## 6. You may change
- name, src and badge — the badge kind
- size — sm, md or lg
- the badge colours for your status system
- the spoken description for screen readers
## 7. Rules
- Three badges ship: verified, admin and new. A fourth is a data-badge rule plus its description.
- Colour must not be the only difference: admin and new carry distinct letters on purpose.
- If your page is not white, change --vibeui-avatar-005-cut or a white halo stays around the badge.
- 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-005.jsonhttps://vibeui.ru/r/avatar-005.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-avatar-005-*. Серверный: хуков нет. Значок отделён от фотографии обводкой box-shadow цветом подложки, поэтому одинаково читается на светлом и тёмном снимке. Вид значка переключается атрибутом data-badge, значение продублировано словами в aria-label. Галочка нарисована двумя бордюрами.
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 Avatar005Badge = "verified" | "admin" | "new"
export type Avatar005Props = Omit<
ComponentPropsWithoutRef<"span">,
"children"
> & {
name?: string
src?: string
badge?: Avatar005Badge
size?: "sm" | "md" | "lg"
}
// Идея компонента: значок в углу аватара. Он вырезает под собой кружок фона
// через обводку цветом страницы, поэтому не сливается с фотографией любой
// яркости. Значение значка продублировано текстом для скринридера: галочка
// сама по себе ничего не сообщает.
const STYLES = `
:where([data-vibeui-block="avatar-005"]){
--vibeui-avatar-005-size:3rem;
--vibeui-avatar-005-hue:250;
--vibeui-avatar-005-bg:oklch(0.92 0.05 var(--vibeui-avatar-005-hue));
--vibeui-avatar-005-fg:oklch(0.38 0.09 var(--vibeui-avatar-005-hue));
--vibeui-avatar-005-cut:oklch(1 0 0);
--vibeui-avatar-005-badge:oklch(0.58 0.15 250);
--vibeui-avatar-005-badge-fg:oklch(0.99 0.01 250);
--vibeui-avatar-005-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="avatar-005"]{
position:relative;display:inline-flex;flex:none;vertical-align:middle;
width:var(--vibeui-avatar-005-size);height:var(--vibeui-avatar-005-size);
font-family:var(--vibeui-avatar-005-font);
}
[data-vibeui-block="avatar-005"][data-size="sm"]{--vibeui-avatar-005-size:2.25rem}
[data-vibeui-block="avatar-005"][data-size="lg"]{--vibeui-avatar-005-size:4rem}
[data-vibeui-block="avatar-005"][data-badge="admin"]{--vibeui-avatar-005-badge:oklch(0.68 0.16 75);--vibeui-avatar-005-badge-fg:oklch(0.24 0.06 75)}
[data-vibeui-block="avatar-005"][data-badge="new"]{--vibeui-avatar-005-badge:oklch(0.62 0.17 152);--vibeui-avatar-005-badge-fg:oklch(0.99 0.01 152)}
[data-vibeui-block="avatar-005"] [data-part="shape"]{
display:flex;align-items:center;justify-content:center;overflow:hidden;
width:100%;height:100%;border-radius:9999px;
background:var(--vibeui-avatar-005-bg);color:var(--vibeui-avatar-005-fg);
font-size:calc(var(--vibeui-avatar-005-size) * 0.34);font-weight:650;line-height:1;user-select:none;
}
[data-vibeui-block="avatar-005"] img{width:100%;height:100%;object-fit:cover;display:block}
/* Значок вырезает под собой кружок обводкой: на светлой и на тёмной
фотографии он одинаково отделён от неё. */
[data-vibeui-block="avatar-005"] [data-part="badge"]{
position:absolute;right:-2%;bottom:-2%;
display:flex;align-items:center;justify-content:center;
width:calc(var(--vibeui-avatar-005-size) * 0.38);
height:calc(var(--vibeui-avatar-005-size) * 0.38);
border-radius:9999px;box-shadow:0 0 0 2px var(--vibeui-avatar-005-cut);
background:var(--vibeui-avatar-005-badge);color:var(--vibeui-avatar-005-badge-fg);
font-size:calc(var(--vibeui-avatar-005-size) * 0.2);font-weight:700;line-height:1;
}
/* Галочка нарисована двумя бордюрами: иконочный пакет ради неё избыточен. */
[data-vibeui-block="avatar-005"] [data-part="tick"]{
width:0.3125rem;height:0.5rem;margin-top:-0.125rem;
border-right:2px solid currentColor;border-bottom:2px solid currentColor;
transform:rotate(45deg);
}
[data-vibeui-block="avatar-005"] [data-part="text"]{
position:absolute;width:1px;height:1px;overflow:hidden;
clip-path:inset(50%);white-space:nowrap;
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="avatar-005"] *{animation:none!important;transition:none!important}}
`
const BADGE_TEXT: Record<Avatar005Badge, string> = {
verified: "подтверждённый аккаунт",
admin: "администратор",
new: "новый участник",
}
// Оттенок из имени: 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 Avatar005({
name = "Марк Ильин",
src = "",
badge = "verified",
size = "md",
className,
style,
...props
}: Avatar005Props) {
const palette = {
"--vibeui-avatar-005-hue": hue(name),
...style,
} as CSSProperties
return (
<>
<style href="vibeui-avatar-005" precedence="medium">
{STYLES}
</style>
<span
{...props}
data-vibeui-block="avatar-005"
data-size={size}
data-badge={badge}
className={className}
style={palette}
role="img"
aria-label={`${name}, ${BADGE_TEXT[badge]}`}
>
<span data-part="shape" aria-hidden="true">
{src ? (
<img src={src} alt="" loading="lazy" decoding="async" />
) : (
initials(name)
)}
</span>
<span data-part="badge" aria-hidden="true">
{badge === "verified" ? (
<span data-part="tick" />
) : badge === "admin" ? (
"A"
) : (
"N"
)}
</span>
</span>
</>
)
}