Badge

Removable Chip

A removable filter chip: the cross is a real button with a name, and a "Restore" button takes the chip's place.

  • badge
  • chip
  • filter
  • removable

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-005?lang=en

London
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-005" (Removable Chip) 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-005.json

Registry item: https://vibeui.ru/r/badge-005.json
Installs to: components/vibeui/badge-005.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 removable filter chip: the cross is a real button with a name, and a "Restore" button takes the chip's place.

An active-filter chip with removal: the cross is a button carrying the full action name, and removal is reversible through a "Restore" button. Zero dependencies, one file, its own palette.

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

<Badge005 label="London" onRemove={() => dropFilter("London")} />

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-005-* palette — do not swap it for your theme tokens
- the aria-label naming the filter: a screen reader reads "×" as a symbol, not an action
- the cross drawn from two bars instead of the × glyph — the typographic sign sits off-centre
- reversibility: a removed filter should come back, not vanish
- a separate button rather than a click on the whole chip — otherwise text cannot be selected
- the focus ring on the cross: it is keyboard-reachable

## 6. You may change
- label — the filter name
- the onRemove handler
- size — sm or md
- the colours for your palette

## 7. Rules
- The component hides itself only for the demo: in a project the caller owns the filter list and onRemove should drop the chip from it.
- A row of removable chips deserves a "Clear all" button: removing ten filters one by one is tiring.
- Never remove a filter on hover: an accidental pass must not change the selection.
- 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-005.json
https://vibeui.ru/r/badge-005.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-badge-005-*. Клиентский: "use client", состояние снятия на useState. Крестик — <button> с aria-label, включающим название фильтра. Сам крестик нарисован двумя полосками: типографский символ × в шрифтах сидит неровно. После снятия на месте плашки остаётся пунктирная кнопка возврата.

Component source

The same file your agent installs. Here in case you would rather copy it by hand.

"use client"

import { useState } from "react"
import type { ComponentPropsWithoutRef, CSSProperties } from "react"

export type Badge005Props = Omit<
  ComponentPropsWithoutRef<"span">,
  "children" | "onRemove"
> & {
  label?: string
  onRemove?: () => void
  size?: "sm" | "md"
}

// Идея компонента: снимаемая плашка фильтра. Крестик — настоящая кнопка с
// собственным именем: «×» без имени скринридер прочитает как «звёздочка» и
// не скажет, что именно снимает. На месте снятой плашки остаётся «Вернуть»:
// исчезнувший без следа фильтр нечем восстановить, кроме памяти.
const STYLES = `
:where([data-vibeui-block="badge-005"]){
--vibeui-badge-005-bg:oklch(0.96 0.004 265);
--vibeui-badge-005-fg:oklch(0.3 0.014 265);
--vibeui-badge-005-border:oklch(0.89 0.006 265);
--vibeui-badge-005-muted:oklch(0.55 0.014 265);
--vibeui-badge-005-accent:oklch(0.55 0.17 265);
--vibeui-badge-005-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="badge-005"]{
display:inline-flex;align-items:center;gap:0.25rem;
height:1.625rem;padding:0 0.25rem 0 0.625rem;
border:1px solid var(--vibeui-badge-005-border);border-radius:9999px;
background:var(--vibeui-badge-005-bg);color:var(--vibeui-badge-005-fg);
font-family:var(--vibeui-badge-005-font);font-size:0.75rem;font-weight:500;
line-height:1;white-space:nowrap;vertical-align:middle;
}
[data-vibeui-block="badge-005"][data-size="sm"]{height:1.375rem;padding:0 0.1875rem 0 0.5rem;font-size:0.6875rem}
[data-vibeui-block="badge-005"][data-gone="true"]{border-color:transparent;background:transparent;padding:0;height:auto}
/* Крестик — кнопка: у неё своя область нажатия и своё имя. */
[data-vibeui-block="badge-005"] button{
appearance:none;border:0;cursor:pointer;background:transparent;
display:inline-flex;align-items:center;justify-content:center;
width:1.125rem;height:1.125rem;padding:0;border-radius:9999px;
color:var(--vibeui-badge-005-muted);
}
[data-vibeui-block="badge-005"] button:hover{background:oklch(0.91 0.006 265);color:var(--vibeui-badge-005-fg)}
[data-vibeui-block="badge-005"] button:focus-visible{outline:2px solid var(--vibeui-badge-005-accent);outline-offset:1px}
/* Крестик нарисован двумя полосками: символ × в шрифтах кривой и прыгает. */
[data-vibeui-block="badge-005"] [data-part="cross"]{position:relative;width:0.5rem;height:0.5rem}
[data-vibeui-block="badge-005"] [data-part="cross"]::before,
[data-vibeui-block="badge-005"] [data-part="cross"]::after{
content:"";position:absolute;left:0;top:50%;width:100%;height:1.5px;
margin-top:-0.75px;background:currentColor;border-radius:9999px;
}
[data-vibeui-block="badge-005"] [data-part="cross"]::before{transform:rotate(45deg)}
[data-vibeui-block="badge-005"] [data-part="cross"]::after{transform:rotate(-45deg)}
/* След снятой плашки: место остаётся, действие обратимо. */
[data-vibeui-block="badge-005"] [data-part="undo"]{
appearance:none;border:1px dashed var(--vibeui-badge-005-border);cursor:pointer;
display:inline-flex;align-items:center;width:auto;height:1.625rem;padding:0 0.625rem;
border-radius:9999px;background:transparent;color:var(--vibeui-badge-005-muted);
font-family:var(--vibeui-badge-005-font);font-size:0.75rem;line-height:1;
}
[data-vibeui-block="badge-005"] [data-part="undo"]:hover{color:var(--vibeui-badge-005-fg)}
[data-vibeui-block="badge-005"] [data-part="undo"]:focus-visible{outline:2px solid var(--vibeui-badge-005-accent);outline-offset:1px}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="badge-005"] *{animation:none!important;transition:none!important}}
`

/**
 * Снимаемая плашка фильтра: крестик — настоящая кнопка с именем.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Badge005({
  label = "Москва",
  onRemove,
  size = "md",
  className,
  style,
  ...props
}: Badge005Props) {
  const [gone, setGone] = useState(false)

  return (
    <>
      <style href="vibeui-badge-005" precedence="medium">
        {STYLES}
      </style>
      <span
        {...props}
        data-vibeui-block="badge-005"
        data-size={size}
        data-gone={gone}
        className={className}
        style={style as CSSProperties}
      >
        {gone ? (
          <button type="button" data-part="undo" onClick={() => setGone(false)}>
            Вернуть «{label}»
          </button>
        ) : null}
        {gone ? null : label}
        {gone ? null : (
          <button
            type="button"
            aria-label={`Снять фильтр «${label}»`}
            onClick={() => {
              setGone(true)
              onRemove?.()
            }}
          >
            <span data-part="cross" aria-hidden="true" />
          </button>
        )}
      </span>
    </>
  )
}