Avatar

Shaped Avatar

An avatar in a non-standard shape: hexagon and squircle are cut with clip-path, the ring is a backing layer — a border would be clipped with the shape.

  • avatar
  • shape
  • clip-path
  • hexagon

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-014?lang=en

Илья МоховFrontend
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-014" (Shaped 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-014.json

Registry item: https://vibeui.ru/r/avatar-014.json
Installs to: components/vibeui/avatar-014.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 non-standard shape: hexagon and squircle are cut with clip-path, the ring is a backing layer — a border would be clipped with the shape.

A clip-path avatar shape set: hexagon, squircle and circle sharing one backing-layer ring. Zero dependencies, one file, no client JS.

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

<Avatar014 name="Ilya Mokhov" role="Frontend" shape="hex" 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-014-* palette — do not swap it for your theme tokens
- clip-path instead of an image mask: the shape must stay crisp at any scale
- the ring as a backing layer, not a border — a border is clipped with the shape
- the optical nudge of the initials in the hexagon: without it the letters look raised
- aria-hidden on the initials, the name is read from the caption
- one shape across a list — mixed shapes read as different entities

## 6. You may change
- the name and the role through role
- the shape through shape
- the size through size
- the ring colour in the variable

## 7. Rules
- The hexagon eats noticeable corners off a portrait: for face photos pick squircle.
- Do not mix shapes in one list: a different shape reads as a different kind of member.
- The role is optional: without it only the name line remains.
- 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-014.json
https://vibeui.ru/r/avatar-014.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-avatar-014-*. Серверный: хуков нет. Формы заданы clip-path (polygon для шестиугольника, скруглением для сквиркла), поэтому остаются резкими на любом масштабе и не тянут за собой картинку-маску. Обводка нарисована отдельной подложкой под clip-path: border режется вместе с фигурой. Инициалы центрируются по прямоугольнику, поэтому у шестиугольника задан оптический сдвиг в 1px — без него буквы кажутся поднятыми.

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 Avatar014Props = Omit<
  ComponentPropsWithoutRef<"span">,
  "children"
> & {
  name?: string
  role?: string
  shape?: "hex" | "squircle" | "circle"
  size?: "sm" | "md" | "lg"
}

// Идея компонента: аватар нестандартной формы. Шестиугольник и «сквиркл»
// сделаны свойством clip-path, а не картинкой-маской: форма остаётся резкой на
// любом масштабе и не тянет файл. Инициалы центрируются по прямоугольнику, а
// не по видимой фигуре, поэтому у шестиугольника задан небольшой оптический
// сдвиг — без него буквы кажутся смещёнными вверх. Обводка нарисована
// подложкой под clip-path: обычный border режется вместе с фигурой.
const STYLES = `
:where([data-vibeui-block="avatar-014"]){
--vibeui-avatar-014-size:3rem;
--vibeui-avatar-014-ring:oklch(0.9 0.006 265);
--vibeui-avatar-014-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="avatar-014"]{
display:inline-flex;align-items:center;gap:0.625rem;
font-family:var(--vibeui-avatar-014-font);
}
/* Обводка — подложка под clip-path: обычный border срезается вместе с фигурой. */
[data-vibeui-block="avatar-014"] [data-part="frame"]{
display:grid;place-items:center;flex:none;
width:var(--vibeui-avatar-014-size);height:var(--vibeui-avatar-014-size);
background:var(--vibeui-avatar-014-ring);
}
[data-vibeui-block="avatar-014"] [data-part="face"]{
display:grid;place-items:center;
width:calc(100% - 2px);height:calc(100% - 2px);
background:oklch(0.9 0.07 var(--vibeui-avatar-014-hue,265));
color:oklch(0.35 0.13 var(--vibeui-avatar-014-hue,265));
font-size:calc(var(--vibeui-avatar-014-size) * 0.34);font-weight:700;line-height:1;
}
[data-vibeui-block="avatar-014"] [data-part="frame"],
[data-vibeui-block="avatar-014"] [data-part="face"]{grid-area:1 / 1}
[data-vibeui-block="avatar-014"] [data-part="frame"]{display:grid}
/* Формы заданы clip-path: остаются резкими на любом масштабе. */
[data-vibeui-block="avatar-014"][data-shape="hex"] [data-part="frame"],
[data-vibeui-block="avatar-014"][data-shape="hex"] [data-part="face"]{
clip-path:polygon(50% 0%,93% 25%,93% 75%,50% 100%,7% 75%,7% 25%);
}
/* Оптический сдвиг: у шестиугольника буквы иначе кажутся выше центра. */
[data-vibeui-block="avatar-014"][data-shape="hex"] [data-part="face"]{padding-top:0.0625rem}
[data-vibeui-block="avatar-014"][data-shape="squircle"] [data-part="frame"],
[data-vibeui-block="avatar-014"][data-shape="squircle"] [data-part="face"]{
border-radius:34%;
}
[data-vibeui-block="avatar-014"][data-shape="circle"] [data-part="frame"],
[data-vibeui-block="avatar-014"][data-shape="circle"] [data-part="face"]{
border-radius:9999px;
}
[data-vibeui-block="avatar-014"][data-size="sm"]{--vibeui-avatar-014-size:2.25rem}
[data-vibeui-block="avatar-014"][data-size="lg"]{--vibeui-avatar-014-size:4rem}
[data-vibeui-block="avatar-014"] [data-part="text"]{display:flex;flex-direction:column;gap:0.0625rem;min-width:0}
[data-vibeui-block="avatar-014"] [data-part="name"]{font-size:0.875rem;font-weight:650}
[data-vibeui-block="avatar-014"] [data-part="role"]{font-size:0.75rem;color:oklch(0.55 0.014 265)}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="avatar-014"] *{animation:none!important;transition:none!important}}
`

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("")
}

/**
 * Аватар нестандартной формы: шестиугольник и «сквиркл» на clip-path.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Avatar014({
  name = "Илья Мохов",
  role = "Фронтенд",
  shape = "hex",
  size = "md",
  className,
  style,
  ...props
}: Avatar014Props) {
  const palette = {
    "--vibeui-avatar-014-hue": hue(name),
    ...style,
  } as CSSProperties

  return (
    <>
      <style href="vibeui-avatar-014" precedence="medium">
        {STYLES}
      </style>
      <span
        {...props}
        data-vibeui-block="avatar-014"
        data-shape={shape}
        data-size={size}
        className={className}
        style={palette}
      >
        <span data-part="frame" aria-hidden="true">
          <span data-part="face">{initials(name)}</span>
        </span>
        <span data-part="text">
          <span data-part="name">{name}</span>
          {role ? <span data-part="role">{role}</span> : null}
        </span>
      </span>
    </>
  )
}