Badge

Count Badge

A counter that never stretches its neighbours: min-width equal to its height, tabular figures and a "99+" cap.

  • badge
  • counter
  • notification
  • numbers

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/badge-003?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-003" (Count 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-003.json

Registry item: https://vibeui.ru/r/badge-003.json
Installs to: components/vibeui/badge-003.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 counter that never stretches its neighbours: min-width equal to its height, tabular figures and a "99+" cap.

A notification counter: a circle at one digit, a "99+" cap, tabular figures and the real number in aria-label. Zero dependencies, one file, no client JS.

## 3. How to use it
import { Badge003 } from "@/components/vibeui/badge-003"

<Badge003 value={128} max={99} label="unread" />

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-003-* palette — do not swap it for your theme tokens
- min-width equal to the height: without it a single digit becomes a narrow sliver
- tabular figures — otherwise the counter twitches on every update
- the "99+" cap: an exact thousand breaks the layout and clarifies nothing
- the real number in aria-label with the visible text under aria-hidden
- dimming a zero rather than hiding it where the layout already reserves the space

## 6. You may change
- value and max
- label — what is being counted
- tone — neutral, accent or danger
- the size through the height variable

## 7. Rules
- Better to render nothing at zero unless the layout reserves the slot: an empty counter distracts.
- Pick the cap for the space you have: a narrow header wants "9+", not "99+".
- This does not position itself over an icon: for a corner marker use badge-004.
- 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-003.json
https://vibeui.ru/r/badge-003.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-badge-003-*. Серверный: хуков нет. Ширина задана min-width в высоту плашки, поэтому однозначное число даёт круг, а не узкую полоску. Цифры табличные. Настоящее значение уходит в aria-label, видимый текст помечен aria-hidden: «99+» вслух бесполезно. Нулевое значение приглушается атрибутом data-zero.

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 Badge003Props = Omit<
  ComponentPropsWithoutRef<"span">,
  "children"
> & {
  value?: number
  /** Порог, после которого печатается «99+». */
  max?: number
  label?: string
  tone?: "neutral" | "accent" | "danger"
}

// Идея компонента: счётчик, который не растягивает соседей. Ширина задана
// минимумом в высоту плашки, цифры табличные, а всё, что больше порога,
// печатается как «99+»: настоящая тысяча уведомлений разорвала бы вёрстку и
// всё равно ничего не сообщила бы точнее.
const STYLES = `
:where([data-vibeui-block="badge-003"]){
--vibeui-badge-003-size:1.25rem;
--vibeui-badge-003-bg:oklch(0.93 0.006 265);
--vibeui-badge-003-fg:oklch(0.3 0.014 265);
--vibeui-badge-003-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="badge-003"]{
display:inline-flex;align-items:center;justify-content:center;
min-width:var(--vibeui-badge-003-size);height:var(--vibeui-badge-003-size);
padding:0 0.375rem;box-sizing:border-box;
border-radius:9999px;
background:var(--vibeui-badge-003-bg);color:var(--vibeui-badge-003-fg);
font-family:var(--vibeui-badge-003-font);font-size:0.6875rem;font-weight:700;
/* Табличные цифры: иначе счётчик дёргается при каждом изменении. */
font-variant-numeric:tabular-nums;line-height:1;vertical-align:middle;
}
[data-vibeui-block="badge-003"][data-tone="accent"]{--vibeui-badge-003-bg:oklch(0.58 0.16 265);--vibeui-badge-003-fg:oklch(0.99 0.01 265)}
[data-vibeui-block="badge-003"][data-tone="danger"]{--vibeui-badge-003-bg:oklch(0.58 0.2 25);--vibeui-badge-003-fg:oklch(0.99 0.01 25)}
[data-vibeui-block="badge-003"][data-zero="true"]{opacity:.45}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="badge-003"] *{animation:none!important;transition:none!important}}
`

/**
 * Счётчик с порогом «99+» и табличными цифрами.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Badge003({
  value = 128,
  max = 99,
  label = "непрочитанных",
  tone = "danger",
  className,
  style,
  ...props
}: Badge003Props) {
  const safe = Math.max(0, Math.round(value))
  const text = safe > max ? `${max}+` : String(safe)

  return (
    <>
      <style href="vibeui-badge-003" precedence="medium">
        {STYLES}
      </style>
      <span
        {...props}
        data-vibeui-block="badge-003"
        data-tone={tone}
        data-zero={safe === 0}
        className={className}
        style={style as CSSProperties}
        aria-label={`${safe} ${label}`}
      >
        <span aria-hidden="true">{text}</span>
      </span>
    </>
  )
}