Avatar

Loading Avatar

An avatar in two states inside one box: the skeleton copies the finished row's geometry to the pixel, so nothing jumps when the data lands.

  • avatar
  • skeleton
  • loading
  • layout-shift

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-026?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-026" (Loading 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-026.json

Registry item: https://vibeui.ru/r/avatar-026.json
Installs to: components/vibeui/avatar-026.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 two states inside one box: the skeleton copies the finished row's geometry to the pixel, so nothing jumps when the data lands.

An avatar with a loading state: the skeleton and the finished row share one box and one geometry, so the content never jumps. Zero dependencies, one file, no client JS.

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

<Avatar026 name="Kim Son" role="Analyst" ready={false} />

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-026-* palette — do not swap it for your theme tokens (bg-muted, animate-pulse and the like)
- both states inside one component: sizes split across files always drift apart
- the hard-coded line heights for name and role — they are what keeps the box identical
- role="status" and aria-busy while loading: without them it does not exist for a screen reader
- bars of different lengths: two equal rectangles read as a table
- the prefers-reduced-motion rule that stops the shimmer

## 6. You may change
- readiness through ready
- name — the name that appears once loaded
- the role through role
- the bone and shimmer colours in the variables

## 7. Rules
- A skeleton is not an explanation: past a couple of seconds show progress or a reason.
- The component loads nothing itself: ready comes from outside.
- If you change the font, re-check the line heights: they are numbers and must match the real text height.
- 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-026.json
https://vibeui.ru/r/avatar-026.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-avatar-026-*. Серверный: хуков нет, состояние приходит пропом ready. Заглушка и готовая строка живут в одном компоненте именно для того, чтобы их размеры нельзя было развести: высоты обеих текстовых строк заданы жёстко и совпадают с высотами полос. Блик — движущийся линейный градиент на 200% ширины; в prefers-reduced-motion он гасится, а полосы заливаются ровным тоном. Пока данных нет, коробка объявлена role="status" с aria-busy.

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 Avatar026Props = Omit<
  ComponentPropsWithoutRef<"div">,
  "children"
> & {
  name?: string
  role?: string
  ready?: boolean
}

// Идея компонента: заглушка и готовая строка живут в одной коробке. Обычная
// «скелетон-версия» рисуется отдельным компонентом, её размеры расходятся с
// настоящими, и при загрузке содержимое прыгает. Здесь круг и обе полосы
// повторяют геометрию имени и роли до пикселя: меняется только заливка.
// Пока данных нет, коробка объявлена role="status" с aria-busy, поэтому
// загрузка существует и для скринридера, а не только для глаз.
const STYLES = `
:where([data-vibeui-block="avatar-026"]){
--vibeui-avatar-026-size:2.75rem;
--vibeui-avatar-026-bg:oklch(1 0 0);
--vibeui-avatar-026-fg:oklch(0.24 0.014 265);
--vibeui-avatar-026-muted:oklch(0.55 0.014 265);
--vibeui-avatar-026-border:oklch(0.91 0.006 265);
--vibeui-avatar-026-bone:oklch(0.93 0.006 265);
--vibeui-avatar-026-shine:oklch(0.97 0.004 265);
--vibeui-avatar-026-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
/* Своя светлая подложка: тёмный текст обязан читаться на любом фоне. */
[data-vibeui-block="avatar-026"]{
display:flex;align-items:center;gap:0.75rem;
box-sizing:border-box;width:100%;max-width:18rem;padding:0.625rem 0.75rem;
background:var(--vibeui-avatar-026-bg);
border:1px solid var(--vibeui-avatar-026-border);border-radius:0.75rem;
font-family:var(--vibeui-avatar-026-font);color:var(--vibeui-avatar-026-fg);
}
[data-vibeui-block="avatar-026"] *{box-sizing:border-box}
[data-vibeui-block="avatar-026"] [data-part="face"]{
display:grid;place-items:center;flex:none;
width:var(--vibeui-avatar-026-size);height:var(--vibeui-avatar-026-size);
border-radius:9999px;
background:oklch(0.9 0.06 var(--vibeui-avatar-026-hue,265));
color:oklch(0.36 0.12 var(--vibeui-avatar-026-hue,265));
font-size:calc(var(--vibeui-avatar-026-size) * 0.34);font-weight:700;line-height:1;
}
[data-vibeui-block="avatar-026"] [data-part="text"]{display:flex;flex-direction:column;gap:0.25rem;min-width:0;flex:1 1 auto}
/* Высоты строк заданы жёстко: заглушка и текст обязаны совпадать. */
[data-vibeui-block="avatar-026"] [data-part="name"]{
height:1.0625rem;font-size:0.875rem;line-height:1.0625rem;font-weight:650;
overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
[data-vibeui-block="avatar-026"] [data-part="role"]{
height:0.9375rem;font-size:0.75rem;line-height:0.9375rem;color:var(--vibeui-avatar-026-muted);
overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
[data-vibeui-block="avatar-026"] [data-part="bone"]{
border-radius:0.3125rem;
background:linear-gradient(90deg,var(--vibeui-avatar-026-bone) 0 40%,var(--vibeui-avatar-026-shine) 50%,var(--vibeui-avatar-026-bone) 60% 100%);
background-size:200% 100%;
animation:vibeui-avatar-026-shine 1.4s infinite linear;
}
[data-vibeui-block="avatar-026"] [data-bone="face"]{
flex:none;width:var(--vibeui-avatar-026-size);height:var(--vibeui-avatar-026-size);border-radius:9999px;
}
[data-vibeui-block="avatar-026"] [data-bone="name"]{height:1.0625rem;width:62%}
[data-vibeui-block="avatar-026"] [data-bone="role"]{height:0.9375rem;width:38%}
@keyframes vibeui-avatar-026-shine{
from{background-position:150% 0}
to{background-position:-50% 0}
}
@media (prefers-reduced-motion:reduce){
[data-vibeui-block="avatar-026"] *{animation:none!important;transition:none!important}
[data-vibeui-block="avatar-026"] [data-part="bone"]{background:var(--vibeui-avatar-026-bone)}
}
`

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 Avatar026({
  name = "Ким Сон",
  role = "Аналитик",
  ready = false,
  className,
  style,
  ...props
}: Avatar026Props) {
  const palette = {
    "--vibeui-avatar-026-hue": hue(name),
    ...style,
  } as CSSProperties

  if (!ready) {
    return (
      <>
        <style href="vibeui-avatar-026" precedence="medium">
          {STYLES}
        </style>
        {/* Загрузка существует и для скринридера, а не только для глаз. */}
        <div
          {...props}
          data-vibeui-block="avatar-026"
          className={className}
          style={palette}
          role="status"
          aria-busy="true"
          aria-label="Загружается участник"
        >
          <span data-part="bone" data-bone="face" />
          <span data-part="text">
            <span data-part="bone" data-bone="name" />
            <span data-part="bone" data-bone="role" />
          </span>
        </div>
      </>
    )
  }

  return (
    <>
      <style href="vibeui-avatar-026" precedence="medium">
        {STYLES}
      </style>
      <div
        {...props}
        data-vibeui-block="avatar-026"
        className={className}
        style={palette}
      >
        <span data-part="face" aria-hidden="true">
          {initials(name)}
        </span>
        <span data-part="text">
          <span data-part="name">{name}</span>
          <span data-part="role">{role}</span>
        </span>
      </div>
    </>
  )
}