Badge
Corner Slot
A slot that pins a badge to the corner of another element: the wrapper adds no padding and the badge never steals the click.
- badge
- slot
- overlay
- counter
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-018?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-018" (Corner Slot) 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-018.json
Registry item: https://vibeui.ru/r/badge-018.json
Installs to: components/vibeui/badge-018.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 slot that pins a badge to the corner of another element: the wrapper adds no padding and the badge never steals the click.
A wrapper slot that places a badge in any of the four corners of a host element without taking its click. Zero dependencies, one file, no client JS.
## 3. How to use it
import { Badge018 } from "@/components/vibeui/badge-018"
<Badge018 content="3" position="top-right" label="new notifications">
<button type="button">Inbox</button>
</Badge018>
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-018-* palette — do not swap it for your theme tokens
- pointer-events:none on the badge — otherwise it intercepts clicks on the button underneath
- the padding-free inline-flex wrapper: any padding shifts the host against its neighbours
- the overhang through a percentage transform: in pixels it breaks at another badge size
- the surface-coloured box-shadow ring: without it the badge merges into the host edge
- the hidden caption with the value: aria-hidden on the badge means the number must be announced separately
## 6. You may change
- the badge content through content
- the corner through position
- the screen-reader caption through label
- the host — any element passed as children
## 7. Rules
- The ring is drawn white: on a coloured surface pass its colour into --vibeui-badge-018-ring or a light halo appears.
- The default host is a placeholder avatar: in production always pass your own element as children.
- The badge sticks out of the wrapper box — a parent with overflow:hidden will clip its corner.
- 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-018.jsonhttps://vibeui.ru/r/badge-018.jsonОдин файл, ноль зависимостей, палитра в локальных переменных --vibeui-badge-018-*. Серверный: хуков нет. Обёртка — inline-flex без отступов, поэтому она сжимается по хосту и не меняет раскладку строки. Плашка абсолютная, угол выбирается атрибутом data-position: он задаёт пару top/right и transform со сдвигом на --vibeui-badge-018-offset, так что вылет считается от собственных габаритов плашки, а не подбирается пикселями под каждый размер хоста. Кольцо box-shadow цвета подложки отделяет плашку от хоста без выреза в нём. pointer-events:none снимает с плашки перехват нажатия: под слотом обычно кнопка, и клик обязан доходить до неё. Значение продублировано скрытой подписью, а сама плашка помечена aria-hidden.
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 Badge018Position =
"top-right" | "top-left" | "bottom-right" | "bottom-left"
export type Badge018Props = ComponentPropsWithoutRef<"span"> & {
content?: string
position?: Badge018Position
label?: string
}
// Идея компонента: слот, который вешает плашку на чужой элемент. Обёртка
// сжимается по содержимому и не добавляет отступов, плашка абсолютная и
// вылетает наружу ровно на долю своей высоты, а pointer-events:none снимает
// с неё перехват нажатия: под слотом обычно кнопка, и клик обязан доходить
// до неё, а не до счётчика.
const STYLES = `
:where([data-vibeui-block="badge-018"]){
--vibeui-badge-018-offset:38%;
--vibeui-badge-018-size:1.125rem;
--vibeui-badge-018-bg:oklch(0.57 0.2 25);
--vibeui-badge-018-fg:oklch(0.99 0.01 25);
--vibeui-badge-018-ring:oklch(1 0 0);
--vibeui-badge-018-host-bg:oklch(0.93 0.008 265);
--vibeui-badge-018-host-fg:oklch(0.34 0.016 265);
--vibeui-badge-018-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="badge-018"]{
position:relative;display:inline-flex;
font-family:var(--vibeui-badge-018-font);vertical-align:middle;
}
[data-vibeui-block="badge-018"] [data-part="badge"]{
position:absolute;z-index:1;
display:inline-flex;align-items:center;justify-content:center;
box-sizing:border-box;
min-width:var(--vibeui-badge-018-size);height:var(--vibeui-badge-018-size);
padding:0 0.3125rem;border-radius:9999px;
background:var(--vibeui-badge-018-bg);color:var(--vibeui-badge-018-fg);
font-size:0.625rem;font-weight:700;line-height:1;font-variant-numeric:tabular-nums;
/* Кольцо цвета подложки отделяет плашку от хоста без выреза в хосте. */
box-shadow:0 0 0 2px var(--vibeui-badge-018-ring);
/* Плашка декоративная: нажатие обязано доходить до элемента под ней. */
pointer-events:none;
}
[data-vibeui-block="badge-018"][data-position="top-right"] [data-part="badge"]{top:0;right:0;transform:translate(var(--vibeui-badge-018-offset),calc(var(--vibeui-badge-018-offset) * -1))}
[data-vibeui-block="badge-018"][data-position="top-left"] [data-part="badge"]{top:0;left:0;transform:translate(calc(var(--vibeui-badge-018-offset) * -1),calc(var(--vibeui-badge-018-offset) * -1))}
[data-vibeui-block="badge-018"][data-position="bottom-right"] [data-part="badge"]{bottom:0;right:0;transform:translate(var(--vibeui-badge-018-offset),var(--vibeui-badge-018-offset))}
[data-vibeui-block="badge-018"][data-position="bottom-left"] [data-part="badge"]{bottom:0;left:0;transform:translate(calc(var(--vibeui-badge-018-offset) * -1),var(--vibeui-badge-018-offset))}
[data-vibeui-block="badge-018"] [data-part="host"]{
display:inline-flex;align-items:center;justify-content:center;
width:2.75rem;height:2.75rem;border-radius:0.875rem;
background:var(--vibeui-badge-018-host-bg);color:var(--vibeui-badge-018-host-fg);
font-size:0.9375rem;font-weight:700;line-height:1;letter-spacing:0.02em;
}
[data-vibeui-block="badge-018"] [data-part="sr"]{
position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;
clip-path:inset(50%);white-space:nowrap;border:0;
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="badge-018"] *{animation:none!important;transition:none!important}}
`
/**
* Слот: сажает плашку в угол чужого элемента, не ломая раскладку.
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Badge018({
content = "3",
position = "top-right",
label = "новых уведомления",
className,
style,
children,
...props
}: Badge018Props) {
return (
<>
<style href="vibeui-badge-018" precedence="medium">
{STYLES}
</style>
<span
{...props}
data-vibeui-block="badge-018"
data-position={position}
className={className}
style={style as CSSProperties}
>
{children ?? <span data-part="host">ЕК</span>}
<span data-part="badge" aria-hidden="true">
{content}
</span>
<span data-part="sr">
{content} {label}
</span>
</span>
</>
)
}