Avatar

Progress Ring

An avatar inside a progress ring: the fill is one variable and the ring is drawn with a gradient, no SVG.

  • avatar
  • progress
  • ring
  • gradient

Preview

1440pxHost theme

Use it with AI

  1. 1. Copy the link.
  2. 2. Write to your agent in your own words and drop the link into the sentence.
  3. 3. The agent opens the link and installs the component from the registry.

put this in the header: https://vibeui.ru/c/avatar-004?lang=en

72%
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-004" (Progress 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-004.json

Registry item: https://vibeui.ru/r/avatar-004.json
Installs to: components/vibeui/avatar-004.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 inside a progress ring: the fill is one variable and the ring is drawn with a gradient, no SVG.

An avatar in a progress ring: a masked conic-gradient instead of SVG, thickness and fill as variables, and the value spelled out in words. Zero dependencies, one file, no client JS.

## 3. How to use it
import { Avatar004 } from "@/components/vibeui/avatar-004"

<Avatar004 name="Anna Petrova" value={72} 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-004-* palette — do not swap it for your theme tokens
- the masked conic-gradient ring: an SVG arc drags in markup and arc-length maths
- the gap between ring and avatar — without it the ring reads as a photo border
- the aria-label with the value: an arc's colour is not read aloud
- clamping the value to 0–100 before converting to degrees
- the ring thickness as a variable rather than a hardcoded pixel value

## 6. You may change
- name, src and value
- size — sm, md or lg
- the accent through the accent prop — the filled arc
- the track colour beneath the arc

## 7. Rules
- The ring is static: animating the fill needs a transition on the variable plus @property — a different component.
- The value is a percentage, not a fraction: 0.72 draws an almost empty ring.
- At tiny sizes the arc blurs together: below 2rem drop the ring.
- 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-004.json
https://vibeui.ru/r/avatar-004.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-avatar-004-*. Серверный: хуков нет. Кольцо — conic-gradient, вырезанный radial-gradient-маской, поэтому толщина меняется одной переменной и не требует ни SVG, ни расчёта длины дуги. Значение приходит в градусах (проценты × 3.6) и продублировано текстом в 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 Avatar004Props = Omit<
  ComponentPropsWithoutRef<"span">,
  "children"
> & {
  name?: string
  src?: string
  /** Заполнение кольца в процентах: прогресс профиля, курса, задачи. */
  value?: number
  size?: "sm" | "md" | "lg"
  accent?: string
}

// Идея компонента: кольцо вокруг аватара показывает прогресс. Оно нарисовано
// conic-gradient и вырезано маской, а не собрано из SVG: одна переменная —
// и кольцо любой толщины, без второго элемента и без вычислений длины дуги.
// Значение продублировано текстом для скринридера: цвет не читается вслух.
const STYLES = `
:where([data-vibeui-block="avatar-004"]){
--vibeui-avatar-004-size:3.5rem;
--vibeui-avatar-004-thickness:0.1875rem;
--vibeui-avatar-004-gap:0.125rem;
--vibeui-avatar-004-value:0deg;
--vibeui-avatar-004-hue:250;
--vibeui-avatar-004-bg:oklch(0.92 0.05 var(--vibeui-avatar-004-hue));
--vibeui-avatar-004-fg:oklch(0.38 0.09 var(--vibeui-avatar-004-hue));
--vibeui-avatar-004-track:oklch(0.9 0.006 265);
--vibeui-avatar-004-accent:oklch(0.62 0.17 265);
--vibeui-avatar-004-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="avatar-004"]{
position:relative;display:inline-flex;align-items:center;justify-content:center;flex:none;
width:var(--vibeui-avatar-004-size);height:var(--vibeui-avatar-004-size);
vertical-align:middle;font-family:var(--vibeui-avatar-004-font);
}
[data-vibeui-block="avatar-004"][data-size="sm"]{--vibeui-avatar-004-size:2.75rem;--vibeui-avatar-004-thickness:0.15rem}
[data-vibeui-block="avatar-004"][data-size="lg"]{--vibeui-avatar-004-size:4.5rem;--vibeui-avatar-004-thickness:0.25rem}
/* Кольцо: conic-gradient, вырезанный маской, без SVG и без расчёта дуги. */
[data-vibeui-block="avatar-004"] [data-part="ring"]{
position:absolute;inset:0;border-radius:9999px;
background:conic-gradient(var(--vibeui-avatar-004-accent) var(--vibeui-avatar-004-value),var(--vibeui-avatar-004-track) 0);
mask:radial-gradient(farthest-side,transparent calc(100% - var(--vibeui-avatar-004-thickness)),oklch(0 0 0) calc(100% - var(--vibeui-avatar-004-thickness)));
}
[data-vibeui-block="avatar-004"] [data-part="shape"]{
position:relative;display:flex;align-items:center;justify-content:center;overflow:hidden;
width:calc(100% - (var(--vibeui-avatar-004-thickness) + var(--vibeui-avatar-004-gap)) * 2);
height:calc(100% - (var(--vibeui-avatar-004-thickness) + var(--vibeui-avatar-004-gap)) * 2);
border-radius:9999px;background:var(--vibeui-avatar-004-bg);color:var(--vibeui-avatar-004-fg);
font-size:calc(var(--vibeui-avatar-004-size) * 0.28);font-weight:650;line-height:1;user-select:none;
}
[data-vibeui-block="avatar-004"] img{width:100%;height:100%;object-fit:cover;display:block}
[data-vibeui-block="avatar-004"] [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-004"] *{animation:none!important;transition:none!important}}
`

// Оттенок из имени: 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 Avatar004({
  name = "Анна Петрова",
  src = "",
  value = 72,
  size = "md",
  accent,
  className,
  style,
  ...props
}: Avatar004Props) {
  const safe = Math.max(0, Math.min(100, value))
  const palette = {
    "--vibeui-avatar-004-hue": hue(name),
    "--vibeui-avatar-004-value": `${safe * 3.6}deg`,
    ...(accent ? { "--vibeui-avatar-004-accent": accent } : null),
    ...style,
  } as CSSProperties

  return (
    <>
      <style href="vibeui-avatar-004" precedence="medium">
        {STYLES}
      </style>
      <span
        {...props}
        data-vibeui-block="avatar-004"
        data-size={size}
        className={className}
        style={palette}
        role="img"
        aria-label={`${name}, профиль заполнен на ${safe}%`}
      >
        <span data-part="ring" aria-hidden="true" />
        <span data-part="shape" aria-hidden="true">
          {src ? (
            <img src={src} alt="" loading="lazy" decoding="async" />
          ) : (
            initials(name)
          )}
        </span>
        <span data-part="text">{safe}%</span>
      </span>
    </>
  )
}