Avatar
Story Ring
An avatar in a story ring: unseen glows with a gradient, seen goes thin and colourless but stays a ring.
- avatar
- story
- ring
- social
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-021?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-021" (Story Ring) 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-021.json
Registry item: https://vibeui.ru/r/avatar-021.json
Installs to: components/vibeui/avatar-021.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 in a story ring: unseen glows with a gradient, seen goes thin and colourless but stays a ring.
An avatar in a story ring: a gradient ring for an unseen story, a thin grey one for a seen story, nothing for people with no stories. The ring is cut with a mask and the state is spelled out. Zero dependencies, one file, no client JS.
## 3. How to use it
import { Avatar021 } from "@/components/vibeui/avatar-021"
<Avatar021 name="Anna Rebrova" state="unseen" 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-021-* palette — do not swap it for your theme tokens
- the radial mask cut-out instead of a background-coloured ring: the gap must hold on any surface
- keeping a ring for the seen state instead of removing it — otherwise "already watched" and "no stories" look the same
- the different thickness across states: one muted colour is not enough for colour-blind users
- the state in words in the hidden caption: a screen reader does not read ring colour
- the button element in the root instead of a div with onClick — a story must open from the keyboard
## 6. You may change
- the name and the state through state — unseen, seen or none
- the size through size — sm, md or lg
- the ring gradient colours in the conic-gradient
- the ring thickness and gap in the ring and gap variables
## 7. Rules
- The component stores no watched flag: the state comes from outside.
- The gradient assumes a light background; check ring contrast on a dark surface.
- The ring takes room around the portrait: budget extra row height in a dense list.
- 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-021.jsonhttps://vibeui.ru/r/avatar-021.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-avatar-021-*. Серверный: хуков нет, корень — обычная кнопка. Кольцо нарисовано conic-gradient и вырезано radial-маской по closest-side, поэтому зазор между рамкой и портретом держится на любом фоне, а толщина меняется одной переменной. Просмотренное состояние не гасится до невидимости: оно теряет цвет и худеет вдвое, но кольцо остаётся — иначе непонятно, есть ли у человека история вообще. Состояние продублировано словом в скрытой подписи.
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 Avatar021Props = Omit<
ComponentPropsWithoutRef<"button">,
"children"
> & {
name?: string
state?: "unseen" | "seen" | "none"
size?: "sm" | "md" | "lg"
}
// Идея компонента: аватар в рамке истории. Кольцо нарисовано conic-gradient и
// вырезано radial-маской, поэтому зазор между рамкой и портретом держится на
// любом фоне — обводка цветом подложки врёт, как только фон меняется.
// Просмотренная история не гаснет до невидимости: она теряет цвет и худеет,
// но остаётся кольцом, иначе непонятно, есть ли у человека история вообще.
const STYLES = `
:where([data-vibeui-block="avatar-021"]){
--vibeui-avatar-021-size:3.25rem;
--vibeui-avatar-021-ring:0.1875rem;
--vibeui-avatar-021-gap:0.1875rem;
--vibeui-avatar-021-seen:oklch(0.78 0.012 265);
--vibeui-avatar-021-focus:oklch(0.55 0.2 262);
--vibeui-avatar-021-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="avatar-021"]{
position:relative;display:inline-grid;place-items:center;
appearance:none;border:0;background:none;cursor:pointer;padding:0;
box-sizing:border-box;
width:calc(var(--vibeui-avatar-021-size) + (var(--vibeui-avatar-021-ring) + var(--vibeui-avatar-021-gap)) * 2);
height:calc(var(--vibeui-avatar-021-size) + (var(--vibeui-avatar-021-ring) + var(--vibeui-avatar-021-gap)) * 2);
font-family:var(--vibeui-avatar-021-font);
}
[data-vibeui-block="avatar-021"] *{box-sizing:border-box}
[data-vibeui-block="avatar-021"]:focus-visible{outline:2px solid var(--vibeui-avatar-021-focus);outline-offset:2px;border-radius:9999px}
/* Кольцо вырезано маской: зазор не зависит от цвета подложки. */
[data-vibeui-block="avatar-021"] [data-part="ring"]{
position:absolute;inset:0;border-radius:9999px;
background:conic-gradient(from -20deg,oklch(0.7 0.19 25),oklch(0.75 0.17 60),oklch(0.68 0.17 310),oklch(0.62 0.18 265),oklch(0.7 0.19 25));
mask-image:radial-gradient(circle closest-side,transparent calc(100% - var(--vibeui-avatar-021-ring)),#000 calc(100% - var(--vibeui-avatar-021-ring)));
transition:transform .18s ease;
}
[data-vibeui-block="avatar-021"][data-state="seen"] [data-part="ring"]{
--vibeui-avatar-021-ring:0.09375rem;
background:var(--vibeui-avatar-021-seen);
}
[data-vibeui-block="avatar-021"][data-state="none"] [data-part="ring"]{display:none}
[data-vibeui-block="avatar-021"]:hover [data-part="ring"]{transform:scale(1.04)}
[data-vibeui-block="avatar-021"] [data-part="face"]{
display:grid;place-items:center;
width:var(--vibeui-avatar-021-size);height:var(--vibeui-avatar-021-size);
border-radius:9999px;
background:oklch(0.9 0.06 var(--vibeui-avatar-021-hue,265));
color:oklch(0.36 0.12 var(--vibeui-avatar-021-hue,265));
font-size:calc(var(--vibeui-avatar-021-size) * 0.34);font-weight:700;line-height:1;
}
[data-vibeui-block="avatar-021"][data-size="sm"]{--vibeui-avatar-021-size:2.25rem}
[data-vibeui-block="avatar-021"][data-size="lg"]{--vibeui-avatar-021-size:4.5rem;--vibeui-avatar-021-ring:0.25rem;--vibeui-avatar-021-gap:0.25rem}
[data-vibeui-block="avatar-021"] [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-021"] *{animation:none!important;transition:none!important}}
`
const STATE_LABEL = {
unseen: "есть новая история",
seen: "история просмотрена",
none: "историй нет",
} 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 Avatar021({
name = "Анна Реброва",
state = "unseen",
size = "md",
type = "button",
className,
style,
...props
}: Avatar021Props) {
const palette = {
"--vibeui-avatar-021-hue": hue(name),
...style,
} as CSSProperties
return (
<>
<style href="vibeui-avatar-021" precedence="medium">
{STYLES}
</style>
<button
{...props}
type={type}
data-vibeui-block="avatar-021"
data-state={state}
data-size={size}
className={className}
style={palette}
>
<span data-part="ring" aria-hidden="true" />
<span data-part="face" aria-hidden="true">
{initials(name)}
</span>
{/* Состояние словом: цвет кольца скринридер не читает. */}
<span data-part="sr">
{name}, {STATE_LABEL[state]}
</span>
</button>
</>
)
}