Buttons

Filter Chip Button

A filter chip made of two buttons in one shape: the left one toggles the filter and carries the match count, the right one clears it and shows only when active.

  • button
  • filter
  • chip
  • counter

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/button-060?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-060" (Filter Chip Button) 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-060.json

Registry item: https://vibeui.ru/r/button-060.json
Installs to: components/vibeui/button-060.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 filter chip made of two buttons in one shape: the left one toggles the filter and carries the match count, the right one clears it and shows only when active.

A filter chip holding two separate buttons: the toggle with its match count and the clear. While off, the chip is light, the number muted and there is no cross — nothing to clear. While on, it fills with the accent, the number inverts and a cross appears on the right. Zero dependencies, one file.

## 3. How to use it
import { Button060 } from "@/components/vibeui/button-060"

<Button060 count={24} onToggle={setStatusFilter} onClear={resetStatus}>
  In progress
</Button060>

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
- two separate buttons instead of a nested one: a nested button is invalid and unusable from the keyboard
- the shared radius and overflow:hidden — otherwise the pair falls apart into two adjacent buttons
- the negative offset on the focus ring: a positive one gets clipped by the wrapper
- the cross appearing only in the on state — an off filter has nothing to clear
- the badge number with tabular-nums: recounting must not shift the chip's width
- aria-pressed on the left button and an explicit name on the cross — 'Clear filter …'

## 6. You may change
- the filter label
- the match count through the count prop
- the initial state through the defaultActive prop
- the accent colour through the accent prop
- the onToggle and onClear handlers

## 7. Rules
- The component filters nothing: it reports state through onToggle and onClear, and the count comes from outside.
- Do not show four-digit numbers in the badge without shortening: the chip is sized for counts up to the hundreds.
- Do not merge the toggle and the clear into one button — the user has to tell 'switch off' from 'clear'.
- 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-060.json
https://vibeui.ru/r/button-060.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-button-060-*. Клиентский компонент: включённость внутренняя, наружу уходит через onToggle и onClear. Вложить кнопку в кнопку нельзя, поэтому обе лежат соседями внутри общей обёртки с overflow:hidden и общим скруглением. Обводка фокуса нарисована с отрицательным offset — иначе она обрезалась бы обёрткой. Включённость объявлена через aria-pressed на левой кнопке.

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,
  MouseEventHandler,
} from "react"

export type Button060Props = Omit<
  ComponentPropsWithoutRef<"div">,
  "children" | "onClick"
> & {
  children?: string
  /** Сколько объектов попадёт под фильтр: число живёт в бейдже. */
  count?: number
  defaultActive?: boolean
  onToggle?: (active: boolean) => void
  onClear?: MouseEventHandler<HTMLButtonElement>
  accent?: string
}

// Идея компонента: фильтр-чип из двух кнопок в одном пятне. Левая включает
// фильтр и несёт число совпадений, правая сбрасывает его — вложить кнопку
// в кнопку нельзя, поэтому они соседи под общим скруглением. Сброс
// появляется только у включённого фильтра: у выключенного сбрасывать нечего.
const STYLES = `
:where([data-vibeui-block="button-060"]){
--vibeui-button-060-surface:oklch(1 0 0);
--vibeui-button-060-border:oklch(0.88 0.006 265);
--vibeui-button-060-fg:oklch(0.28 0.02 265);
--vibeui-button-060-accent:oklch(0.5 0.16 285);
--vibeui-button-060-accent-fg:oklch(0.99 0.01 285);
--vibeui-button-060-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="button-060"]{
display:inline-flex;align-items:stretch;box-sizing:border-box;overflow:hidden;
height:2.25rem;border-radius:9999px;
border:1px solid var(--vibeui-button-060-border);
background:var(--vibeui-button-060-surface);color:var(--vibeui-button-060-fg);
font-family:var(--vibeui-button-060-font);
transition:border-color .16s ease,background-color .16s ease,color .16s ease;
}
[data-vibeui-block="button-060"][data-active="true"]{
background:var(--vibeui-button-060-accent);color:var(--vibeui-button-060-accent-fg);
border-color:var(--vibeui-button-060-accent);
}
[data-vibeui-block="button-060"] button{
appearance:none;border:0;background:transparent;cursor:pointer;color:inherit;
display:inline-flex;align-items:center;gap:0.4375rem;
font:inherit;font-size:0.8125rem;font-weight:650;line-height:1;
transition:background-color .16s ease;
}
[data-vibeui-block="button-060"] [data-part="chip"]{padding:0 0.5rem 0 0.875rem}
[data-vibeui-block="button-060"] [data-part="chip"]:hover{background:oklch(0.5 0.02 265 / 8%)}
[data-vibeui-block="button-060"] button:focus-visible{outline:2px solid var(--vibeui-button-060-accent);outline-offset:-3px;border-radius:9999px}
[data-vibeui-block="button-060"][data-active="true"] button:focus-visible{outline-color:var(--vibeui-button-060-accent-fg)}
/* Бейдж числа: у выключенного фильтра он приглушён, у включённого — вывернут. */
[data-vibeui-block="button-060"] [data-part="count"]{
min-width:1.375rem;padding:0.1875rem 0.375rem;border-radius:9999px;
background:color-mix(in oklab,var(--vibeui-button-060-accent) 12%,transparent);
color:var(--vibeui-button-060-accent);
font-size:0.6875rem;font-weight:700;font-variant-numeric:tabular-nums;text-align:center;
}
[data-vibeui-block="button-060"][data-active="true"] [data-part="count"]{
background:oklch(1 0 0 / 22%);color:var(--vibeui-button-060-accent-fg);
}
[data-vibeui-block="button-060"] [data-part="clear"]{
padding:0 0.75rem 0 0.5rem;
box-shadow:inset 1px 0 0 0 oklch(1 0 0 / 30%);
}
[data-vibeui-block="button-060"] [data-part="clear"]:hover{background:oklch(0 0 0 / 12%)}
[data-vibeui-block="button-060"] [data-part="cross"]{position:relative;width:0.625rem;height:0.625rem}
[data-vibeui-block="button-060"] [data-part="cross"]::before,
[data-vibeui-block="button-060"] [data-part="cross"]::after{
content:"";position:absolute;left:50%;top:50%;width:0.625rem;height:1.5px;
margin:-0.75px 0 0 -0.3125rem;background:currentColor;border-radius:1px;
}
[data-vibeui-block="button-060"] [data-part="cross"]::before{transform:rotate(45deg)}
[data-vibeui-block="button-060"] [data-part="cross"]::after{transform:rotate(-45deg)}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="button-060"] *{animation:none!important;transition:none!important}}
`

/**
 * Фильтр-чип с числом совпадений и отдельной кнопкой сброса.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Button060({
  children = "В работе",
  count = 24,
  defaultActive = true,
  onToggle,
  onClear,
  accent,
  className,
  style,
  ...props
}: Button060Props) {
  const [active, setActive] = useState(defaultActive)

  const palette = {
    ...(accent ? { "--vibeui-button-060-accent": accent } : null),
    ...style,
  } as CSSProperties

  return (
    <>
      <style href="vibeui-button-060" precedence="medium">
        {STYLES}
      </style>
      <div
        {...props}
        data-vibeui-block="button-060"
        data-active={String(active)}
        className={className}
        style={palette}
      >
        <button
          type="button"
          data-part="chip"
          aria-pressed={active}
          onClick={() => {
            const next = !active

            setActive(next)
            onToggle?.(next)
          }}
        >
          {children}
          <span data-part="count">{count}</span>
        </button>
        {active ? (
          <button
            type="button"
            data-part="clear"
            aria-label={`Сбросить фильтр «${children}»`}
            onClick={(event) => {
              setActive(false)
              onClear?.(event)
            }}
          >
            <span data-part="cross" aria-hidden="true" />
          </button>
        ) : null}
      </div>
    </>
  )
}