Buttons
Notification Badge
A counter over the corner of the button: the number lands in both the badge and the aria-label, large values collapse into 99+, and zero removes the badge entirely.
- button
- badge
- counter
- notifications
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/button-030?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 "button-030" (Notification 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/button-030.json
Registry item: https://vibeui.ru/r/button-030.json
Installs to: components/vibeui/button-030.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 over the corner of the button: the number lands in both the badge and the aria-label, large values collapse into 99+, and zero removes the badge entirely.
An icon button with an unread counter in its corner. The number is visible in the badge and audible in the aria-label, so 12 unread is not only a picture. Values above the cap collapse into 99+, zero removes the badge along with its halo, and a ring in the surface colour keeps the digit off the bell beneath it.
## 3. How to use it
import { Button030 } from "@/components/vibeui/button-030"
<Button030 label="Notifications" count={12} onClick={openInbox} />
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 number in both the badge and the aria-label: a counter that is never spoken does not exist for a screen reader
- the ring in the surface colour around the badge — without it the digit melts into the glyph below
- collapsing large values into 99+: otherwise the badge stretches the button and breaks the row
- the badge disappearing at zero rather than showing a zero — an empty counter is no counter
- tabular-nums on the digits so the badge keeps its width across values
- the prefers-reduced-motion rule, which removes the pulsing halo completely
## 6. You may change
- the button name through the label prop, which goes into the aria-label with the number
- the value through the count prop, computed by your app
- the collapse threshold through the cap prop
- the badge colour through the badge prop
- outer spacing through className
## 7. Rules
- The component polls nothing: count arrives from outside, there is no timer and no request inside.
- Do not leave the pulse on a counter that is always present: it is meant for something genuinely new, not for background.
- The aria-label phrase is written in Russian in the code — translate it along with the rest of the interface.
- 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/button-030.jsonhttps://vibeui.ru/r/button-030.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-button-030-*. Серверный: число приходит пропом count, компонент ничего не считает сам. Бейдж обведён кольцом цвета подложки через box-shadow, поэтому не сливается с колокольчиком. Порог схлопывания задаётся пропом cap. Ореол — CSS-анимация, которая полностью выключается при prefers-reduced-motion.
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 Button030Props = Omit<
ComponentPropsWithoutRef<"button">,
"children"
> & {
label?: string
/** Сколько непрочитанного. Ноль прячет бейдж целиком. */
count?: number
/** С какого числа показывать «99+». */
cap?: number
badge?: string
}
// Идея компонента: счётчик поверх угла кнопки. Число попадает и в бейдж, и в
// aria-label, поэтому «12 непрочитанных» слышно, а не только видно. Бейдж
// обведён кольцом цвета подложки — иначе цифра на границе значка теряется, —
// а большие числа схлопываются в «99+», чтобы кнопка не растягивалась.
const STYLES = `
:where([data-vibeui-block="button-030"]){
--vibeui-button-030-bg:oklch(1 0 0);
--vibeui-button-030-fg:oklch(0.32 0.016 265);
--vibeui-button-030-border:oklch(0.9 0.006 265);
--vibeui-button-030-accent:oklch(0.55 0.17 265);
--vibeui-button-030-badge:oklch(0.55 0.19 25);
--vibeui-button-030-badge-fg:oklch(0.99 0.01 25);
--vibeui-button-030-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="button-030"]{
appearance:none;cursor:pointer;position:relative;
display:inline-flex;align-items:center;justify-content:center;
width:2.5rem;height:2.5rem;padding:0;box-sizing:border-box;
border:1px solid var(--vibeui-button-030-border);border-radius:0.75rem;
background:var(--vibeui-button-030-bg);color:var(--vibeui-button-030-fg);
font-family:var(--vibeui-button-030-font);
transition:color .16s ease,border-color .16s ease;
}
[data-vibeui-block="button-030"]:hover{color:var(--vibeui-button-030-accent);border-color:var(--vibeui-button-030-accent)}
[data-vibeui-block="button-030"]:focus-visible{outline:2px solid var(--vibeui-button-030-accent);outline-offset:2px}
[data-vibeui-block="button-030"] [data-part="bell"]{
position:relative;width:0.875rem;height:0.8125rem;box-sizing:border-box;
border:1.5px solid currentColor;border-bottom:0;border-radius:0.5rem 0.5rem 0.0625rem 0.0625rem;
}
[data-vibeui-block="button-030"] [data-part="bell"]::before{
content:"";position:absolute;left:-0.1875rem;bottom:-1.5px;width:1.1875rem;height:1.5px;
border-radius:1px;background:currentColor;
}
[data-vibeui-block="button-030"] [data-part="bell"]::after{
content:"";position:absolute;left:50%;bottom:-0.3125rem;width:0.3125rem;height:0.1875rem;
margin-left:-0.15625rem;border-radius:0 0 0.15625rem 0.15625rem;background:currentColor;
}
/* Кольцо цвета подложки: цифра не липнет к краю значка. */
[data-vibeui-block="button-030"] [data-part="badge"]{
position:absolute;top:-0.3125rem;right:-0.3125rem;
display:inline-flex;align-items:center;justify-content:center;
min-width:1.125rem;height:1.125rem;padding:0 0.25rem;box-sizing:border-box;
border-radius:9999px;
background:var(--vibeui-button-030-badge);color:var(--vibeui-button-030-badge-fg);
box-shadow:0 0 0 2px var(--vibeui-button-030-bg);
font-size:0.6875rem;font-weight:700;line-height:1;font-variant-numeric:tabular-nums;
}
[data-vibeui-block="button-030"] [data-part="halo"]{
position:absolute;top:-0.3125rem;right:-0.3125rem;
width:1.125rem;height:1.125rem;border-radius:9999px;
background:var(--vibeui-button-030-badge);
animation:vibeui-button-030-halo 2.4s ease-out infinite;
}
@keyframes vibeui-button-030-halo{
0%{opacity:.45;transform:scale(1)}
70%,100%{opacity:0;transform:scale(1.9)}
}
@media (prefers-reduced-motion:reduce){
[data-vibeui-block="button-030"] *{animation:none!important;transition:none!important}
[data-vibeui-block="button-030"] [data-part="halo"]{display:none}
}
`
/**
* Иконочная кнопка со счётчиком непрочитанного в углу.
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Button030({
label = "Уведомления",
count = 12,
cap = 99,
badge,
type = "button",
className,
style,
...props
}: Button030Props) {
const shown = count > cap ? `${cap}+` : String(count)
const palette = {
...(badge ? { "--vibeui-button-030-badge": badge } : null),
...style,
} as CSSProperties
return (
<>
<style href="vibeui-button-030" precedence="medium">
{STYLES}
</style>
<button
{...props}
type={type}
data-vibeui-block="button-030"
className={className}
style={palette}
aria-label={count > 0 ? `${label}: ${count} непрочитанных` : label}
>
<span data-part="bell" aria-hidden="true" />
{count > 0 ? (
<>
<span data-part="halo" aria-hidden="true" />
<span data-part="badge" aria-hidden="true">
{shown}
</span>
</>
) : null}
</button>
</>
)
}