Avatar

Country Flag Avatar

An avatar with a country flag in the corner: the flag is drawn with gradients rather than emoji, and the country is spelled out.

  • avatar
  • country
  • flag
  • locale

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

Люси МартенLyon, Франция
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-024" (Country Flag 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-024.json

Registry item: https://vibeui.ru/r/avatar-024.json
Installs to: components/vibeui/avatar-024.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 country flag in the corner: the flag is drawn with gradients rather than emoji, and the country is spelled out.

An avatar with a country flag in the corner: four flags drawn with gradients, with the country named in words next to the city. Zero dependencies, one file, no client JS.

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

<Avatar024 name="Lucie Martin" country="fr" city="Lyon" />

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-024-* palette — do not swap it for your theme tokens
- gradient flags instead of emoji: on Windows a flag emoji renders as two code letters
- the rectangular flag shape — a round corner badge already means presence
- the country in words: flag stripes are not recognised by everyone
- the card-coloured ring and the thin inner outline — white stripes vanish without them
- the card's own light surface: without it the dark text disappears on a dark background

## 6. You may change
- the name and the country through country
- the city through city
- the country set — a new flag is one gradient rule plus a dictionary line
- the portrait and flag sizes in the variables

## 7. Rules
- Four flags ship: fr, de, it and jp. A fifth is a data-country rule plus a dictionary entry.
- A country flag is neither citizenship nor language: do not use it to label the interface locale.
- Gradient flags are simplified to stripes: exact heraldry needs SVG, and that is a different component.
- 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-024.json
https://vibeui.ru/r/avatar-024.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-avatar-024-*. Серверный: хуков нет. Флаги нарисованы линейными и радиальными градиентами: эмодзи-флаги в Windows рисуются двумя буквами, и «FR» вместо полотнища ломает всю затею, а картинки потянули бы за собой сеть. Флажок прямоугольный и отделён обводкой цвета карточки — круглый значок в углу занят присутствием, и путать эти смыслы нельзя. Страна названа словом в строке под именем.

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 Avatar024Props = Omit<
  ComponentPropsWithoutRef<"div">,
  "children"
> & {
  name?: string
  country?: "fr" | "de" | "it" | "jp"
  city?: string
}

// Идея компонента: аватар с флагом страны в углу. Флаг нарисован градиентами,
// а не эмодзи: эмодзи-флаги на Windows рисуются двумя буквами, и «FR» вместо
// полотнища ломает всю затею. Флажок прямоугольный — круглый значок в углу
// уже занят присутствием, и путать эти смыслы нельзя. Страна продублирована
// словом в строке под именем: полоски без подписи угадываются не всеми.
const STYLES = `
:where([data-vibeui-block="avatar-024"]){
--vibeui-avatar-024-size:2.75rem;
--vibeui-avatar-024-flag:1.375rem;
--vibeui-avatar-024-bg:oklch(1 0 0);
--vibeui-avatar-024-fg:oklch(0.24 0.014 265);
--vibeui-avatar-024-muted:oklch(0.55 0.014 265);
--vibeui-avatar-024-border:oklch(0.91 0.006 265);
--vibeui-avatar-024-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
/* Своя светлая подложка: тёмный текст обязан читаться на любом фоне. */
[data-vibeui-block="avatar-024"]{
display:flex;align-items:center;gap:0.75rem;
box-sizing:border-box;width:100%;max-width:18rem;padding:0.5rem 0.75rem;
background:var(--vibeui-avatar-024-bg);
border:1px solid var(--vibeui-avatar-024-border);border-radius:0.75rem;
font-family:var(--vibeui-avatar-024-font);color:var(--vibeui-avatar-024-fg);
}
[data-vibeui-block="avatar-024"] *{box-sizing:border-box}
[data-vibeui-block="avatar-024"] [data-part="slot"]{position:relative;flex:none}
[data-vibeui-block="avatar-024"] [data-part="face"]{
display:grid;place-items:center;
width:var(--vibeui-avatar-024-size);height:var(--vibeui-avatar-024-size);
border-radius:9999px;
background:oklch(0.9 0.06 var(--vibeui-avatar-024-hue,265));
color:oklch(0.36 0.12 var(--vibeui-avatar-024-hue,265));
font-size:calc(var(--vibeui-avatar-024-size) * 0.34);font-weight:700;line-height:1;
}
/* Прямоугольник, а не кружок: круглый значок в углу занят присутствием. */
[data-vibeui-block="avatar-024"] [data-part="flag"]{
position:absolute;right:-0.25rem;bottom:-0.125rem;
width:var(--vibeui-avatar-024-flag);
height:calc(var(--vibeui-avatar-024-flag) * 0.67);
border-radius:0.1875rem;overflow:hidden;
box-shadow:0 0 0 0.125rem var(--vibeui-avatar-024-bg),inset 0 0 0 1px oklch(0.2 0 0 / 18%);
}
[data-vibeui-block="avatar-024"][data-country="fr"] [data-part="flag"]{background:linear-gradient(90deg,#0055a4 0 33.34%,#ffffff 33.34% 66.67%,#ef4135 66.67%)}
[data-vibeui-block="avatar-024"][data-country="de"] [data-part="flag"]{background:linear-gradient(180deg,#000000 0 33.34%,#dd0000 33.34% 66.67%,#ffce00 66.67%)}
[data-vibeui-block="avatar-024"][data-country="it"] [data-part="flag"]{background:linear-gradient(90deg,#008c45 0 33.34%,#f4f5f0 33.34% 66.67%,#cd212a 66.67%)}
[data-vibeui-block="avatar-024"][data-country="jp"] [data-part="flag"]{background:radial-gradient(circle at 50% 50%,#bc002d 0 32%,#ffffff 32%)}
[data-vibeui-block="avatar-024"] [data-part="text"]{display:flex;flex-direction:column;gap:0.0625rem;min-width:0}
[data-vibeui-block="avatar-024"] [data-part="name"]{
font-size:0.875rem;font-weight:650;
overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
[data-vibeui-block="avatar-024"] [data-part="place"]{
font-size:0.75rem;color:var(--vibeui-avatar-024-muted);
overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="avatar-024"] *{animation:none!important;transition:none!important}}
`

const COUNTRY_LABEL = {
  fr: "Франция",
  de: "Германия",
  it: "Италия",
  jp: "Япония",
} 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 Avatar024({
  name = "Люси Мартен",
  country = "fr",
  city = "Лион",
  className,
  style,
  ...props
}: Avatar024Props) {
  const palette = {
    "--vibeui-avatar-024-hue": hue(name),
    ...style,
  } as CSSProperties

  return (
    <>
      <style href="vibeui-avatar-024" precedence="medium">
        {STYLES}
      </style>
      <div
        {...props}
        data-vibeui-block="avatar-024"
        data-country={country}
        className={className}
        style={palette}
      >
        <span data-part="slot">
          <span data-part="face" aria-hidden="true">
            {initials(name)}
          </span>
          <span data-part="flag" aria-hidden="true" />
        </span>
        <span data-part="text">
          <span data-part="name">{name}</span>
          {/* Страна словом: полоски флага угадываются не всеми. */}
          <span data-part="place">
            {city}, {COUNTRY_LABEL[country]}
          </span>
        </span>
      </div>
    </>
  )
}