Badge
Size Scale
A badge with a size scale: sm, md and lg change one grid step, and height, type size, padding, radius and dot are all computed from it.
- badge
- size
- scale
- tokens
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/badge-015?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 "badge-015" (Size Scale) 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/badge-015.json
Registry item: https://vibeui.ru/r/badge-015.json
Installs to: components/vibeui/badge-015.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
A badge with a size scale: sm, md and lg change one grid step, and height, type size, padding, radius and dot are all computed from it.
A badge in three sizes whose every metric is derived from a single grid step through calc. Zero dependencies, one file, no client JS.
## 3. How to use it
import { Badge015 } from "@/components/vibeui/badge-015"
<Badge015 size="lg" count={8}>
In progress
</Badge015>
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-badge-015-* palette — do not swap it for your theme tokens
- deriving the metrics from one step: hand-typed sizes drift apart by the second variant
- the multipliers in calc — they are the proportion the scale exists for
- tabular figures in the counter: otherwise the badge jitters on every change
- align-self:stretch on the divider so the line spans the full height at any size
- the badge's own light surface: without it the dark text disappears on a dark background
## 6. You may change
- the size through size
- the trailing number through count
- the caption through children
- the steps of the scale in the data-size rules
## 7. Rules
- There are three sizes: a fourth is one line with a new --unit, not a separate set of rules.
- The sm type size lands at 0.75rem — going lower makes the text unreadable.
- count is not drawn at zero: the badge shrinks, which shows in a table — set a minimum if you need a stable width.
- 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/badge-015.jsonhttps://vibeui.ru/r/badge-015.jsonОдин файл, ноль зависимостей, палитра в локальных переменных --vibeui-badge-015-*. Серверный: хуков нет. Атрибут data-size задаёт единственное число --vibeui-badge-015-unit, остальное собрано через calc от него: высота — шесть шагов, кегль — три, горизонтальный отступ — 2.4, радиус — три, точка и зазор — 1.6. Поэтому маленькая плашка не выглядит уменьшенной копией: пропорции остаются теми же, а не подбираются на глаз для каждого размера. Хвостовой счётчик отделён вертикальной линией на всю высоту (align-self:stretch), чтобы разделитель не приходилось подгонять под кегль.
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 Badge015Props = ComponentPropsWithoutRef<"span"> & {
size?: "sm" | "md" | "lg"
count?: number
}
// Идея компонента: размерная шкала из одной переменной. Атрибут size меняет
// только шаг сетки --unit, а высота, кегль, отступы, радиус, точка и зазор
// считаются от него через calc. Поэтому маленькая плашка не выглядит просто
// уменьшенной копией: пропорции сохраняются, а не масштабируются на глаз.
const STYLES = `
:where([data-vibeui-block="badge-015"]){
--vibeui-badge-015-unit:0.3125rem;
--vibeui-badge-015-bg:oklch(0.97 0.004 265);
--vibeui-badge-015-fg:oklch(0.3 0.014 265);
--vibeui-badge-015-border:oklch(0.9 0.006 265);
--vibeui-badge-015-accent:oklch(0.55 0.16 265);
--vibeui-badge-015-muted:oklch(0.55 0.014 265);
--vibeui-badge-015-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="badge-015"][data-size="sm"]{--vibeui-badge-015-unit:0.25rem}
[data-vibeui-block="badge-015"][data-size="md"]{--vibeui-badge-015-unit:0.3125rem}
[data-vibeui-block="badge-015"][data-size="lg"]{--vibeui-badge-015-unit:0.375rem}
[data-vibeui-block="badge-015"]{
display:inline-flex;align-items:center;box-sizing:border-box;
/* Всё до единого размера — производные шага, никаких отдельных таблиц. */
gap:calc(var(--vibeui-badge-015-unit) * 1.6);
height:calc(var(--vibeui-badge-015-unit) * 6);
padding:0 calc(var(--vibeui-badge-015-unit) * 2.4);
border:1px solid var(--vibeui-badge-015-border);
border-radius:calc(var(--vibeui-badge-015-unit) * 3);
background:var(--vibeui-badge-015-bg);color:var(--vibeui-badge-015-fg);
font-family:var(--vibeui-badge-015-font);
font-size:calc(var(--vibeui-badge-015-unit) * 3);
font-weight:600;line-height:1;vertical-align:middle;
}
[data-vibeui-block="badge-015"] [data-part="dot"]{
flex:none;border-radius:9999px;background:var(--vibeui-badge-015-accent);
width:calc(var(--vibeui-badge-015-unit) * 1.6);
height:calc(var(--vibeui-badge-015-unit) * 1.6);
}
[data-vibeui-block="badge-015"] [data-part="count"]{
color:var(--vibeui-badge-015-muted);font-variant-numeric:tabular-nums;font-weight:500;
padding-left:calc(var(--vibeui-badge-015-unit) * 1.2);
margin-left:calc(var(--vibeui-badge-015-unit) * 0.4);
border-left:1px solid var(--vibeui-badge-015-border);
align-self:stretch;display:inline-flex;align-items:center;
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="badge-015"] *{animation:none!important;transition:none!important}}
`
/**
* Плашка с размерной шкалой sm/md/lg: всё считается от одного шага.
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Badge015({
size = "md",
count = 8,
className,
style,
children = "В работе",
...props
}: Badge015Props) {
const safe = Math.max(0, Math.round(count))
return (
<>
<style href="vibeui-badge-015" precedence="medium">
{STYLES}
</style>
<span
{...props}
data-vibeui-block="badge-015"
data-size={size}
className={className}
style={style as CSSProperties}
>
<span data-part="dot" aria-hidden="true" />
{children}
{safe > 0 ? <span data-part="count">{safe}</span> : null}
</span>
</>
)
}