Badge
Trend Badge
A metric change with an arrow: what counts as good is set by the caller — for churn, growth is bad news.
- badge
- trend
- metrics
- dashboard
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-007?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-007" (Trend Badge) 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-007.json
Registry item: https://vibeui.ru/r/badge-007.json
Installs to: components/vibeui/badge-007.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 metric change with an arrow: what counts as good is set by the caller — for churn, growth is bad news.
A metric-change badge: arrow, sign, percentage and period. The good direction comes from outside, so falling churn turns green. Zero dependencies, one file, no client JS.
## 3. How to use it
import { Badge007 } from "@/components/vibeui/badge-007"
<Badge007 value={-3.2} goodDirection="down" period="this month" />
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-007-* palette — do not swap it for your theme tokens
- the goodDirection prop: revenue growth and churn growth are different news, and the component must not decide
- the sign and arrow alongside colour — colour vanishes in black and white
- tabular figures: in a column of metrics the values must line up
- a distinct zero state: an up arrow on no change is a lie
- the period in small type — "+12%" without a period says nothing
## 6. You may change
- value and unit
- goodDirection — up or down
- period — over what span
- the good and bad colours for your palette
## 7. Rules
- The value arrives ready: the component computes and rounds nothing.
- For percentage points change the unit to "pp" — they must not be confused with percentages.
- Colour does not replace a label: the metric's name belongs next to the badge.
- 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-007.jsonhttps://vibeui.ru/r/badge-007.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-badge-007-*. Серверный: хуков нет. Направление считается из знака значения, а окраска — из совпадения направления с пропом goodDirection. Стрелка нарисована двумя бордюрами и поворачивается трансформацией; при нулевом изменении превращается в горизонтальную черту. Цифры табличные, знак минус — типографский.
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 Badge007Props = Omit<
ComponentPropsWithoutRef<"span">,
"children"
> & {
value?: number
/** Что считаем ростом: у расходов и оттока рост — это плохо. */
goodDirection?: "up" | "down"
unit?: string
period?: string
}
// Идея компонента: изменение показателя со стрелкой. Хорошее направление
// задаётся снаружи: рост выручки — зелёный, рост оттока — красный, и
// компонент не имеет права решать это за вас. Знак и стрелка дублируют цвет,
// поэтому значение читается и в чёрно-белом виде.
const STYLES = `
:where([data-vibeui-block="badge-007"]){
--vibeui-badge-007-bg:oklch(0.96 0.004 265);
--vibeui-badge-007-fg:oklch(0.32 0.014 265);
--vibeui-badge-007-muted:oklch(0.55 0.014 265);
--vibeui-badge-007-good:oklch(0.55 0.15 152);
--vibeui-badge-007-bad:oklch(0.55 0.18 25);
--vibeui-badge-007-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="badge-007"]{
display:inline-flex;align-items:center;gap:0.3125rem;
height:1.5rem;padding:0 0.5625rem;
border-radius:0.4375rem;
background:var(--vibeui-badge-007-bg);color:var(--vibeui-badge-007-fg);
font-family:var(--vibeui-badge-007-font);font-size:0.75rem;font-weight:600;
font-variant-numeric:tabular-nums;line-height:1;white-space:nowrap;vertical-align:middle;
}
[data-vibeui-block="badge-007"][data-mood="good"]{color:var(--vibeui-badge-007-good);background:color-mix(in oklab,var(--vibeui-badge-007-good) 12%,oklch(1 0 0))}
[data-vibeui-block="badge-007"][data-mood="bad"]{color:var(--vibeui-badge-007-bad);background:color-mix(in oklab,var(--vibeui-badge-007-bad) 12%,oklch(1 0 0))}
[data-vibeui-block="badge-007"][data-mood="flat"]{color:var(--vibeui-badge-007-muted)}
/* Стрелка из двух бордюров: направление видно и без цвета. */
[data-vibeui-block="badge-007"] [data-part="arrow"]{
flex:none;width:0.4375rem;height:0.4375rem;
border-top:1.5px solid currentColor;border-right:1.5px solid currentColor;
}
[data-vibeui-block="badge-007"][data-direction="up"] [data-part="arrow"]{transform:rotate(-45deg) translate(0.0625rem,0.0625rem)}
[data-vibeui-block="badge-007"][data-direction="down"] [data-part="arrow"]{transform:rotate(135deg) translate(0.0625rem,0.0625rem)}
[data-vibeui-block="badge-007"][data-direction="flat"] [data-part="arrow"]{
border-top:0;border-right:0;height:0;width:0.5rem;
border-bottom:1.5px solid currentColor;
}
[data-vibeui-block="badge-007"] [data-part="period"]{font-weight:500;color:var(--vibeui-badge-007-muted)}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="badge-007"] *{animation:none!important;transition:none!important}}
`
/**
* Изменение показателя: стрелка, знак и цвет по заданному направлению.
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Badge007({
value = 12.4,
goodDirection = "up",
unit = "%",
period = "за неделю",
className,
style,
...props
}: Badge007Props) {
const direction = value > 0 ? "up" : value < 0 ? "down" : "flat"
const mood =
direction === "flat" ? "flat" : direction === goodDirection ? "good" : "bad"
const sign = value > 0 ? "+" : value < 0 ? "−" : ""
const text = `${sign}${Math.abs(value)}${unit}`
return (
<>
<style href="vibeui-badge-007" precedence="medium">
{STYLES}
</style>
<span
{...props}
data-vibeui-block="badge-007"
data-direction={direction}
data-mood={mood}
className={className}
style={style as CSSProperties}
>
<span data-part="arrow" aria-hidden="true" />
{text}
{period ? <span data-part="period">{period}</span> : null}
</span>
</>
)
}