Inputs

Active Chips

A row of active filters: every chip names its group and value, comes off one at a time, and "reset all" only appears from two conditions.

  • filters
  • chips
  • reset
  • catalog

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/filters-002?lang=en

Активные фильтры

128 components found

  • Категория:Формы
  • Цена:до 5000 ₽
  • Лицензия:MIT
  • Обновлён:за месяц
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 "filters-002" (Active Chips) 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/filters-002.json

Registry item: https://vibeui.ru/r/filters-002.json
Installs to: components/vibeui/filters-002.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 row of active filters: every chip names its group and value, comes off one at a time, and "reset all" only appears from two conditions.

A row of what is already on: chips carrying the group name and the value, one-by-one removal, a result counter and a separate reset for the whole set. Zero dependencies, one file, its own palette.

## 3. How to use it
import { Filters002 } from "@/components/vibeui/filters-002"

<Filters002
  chips={[{ id: "1", group: "Price", value: "under £50" }]}
  total="128 components found"
/>

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-filters-002-* palette — do not swap it for your theme tokens (bg-muted, border-input and the like)
- the group name inside the chip: "under 5000" means nothing without the word "Price"
- the remove button labelled with group and value rather than "remove" — aloud it is otherwise unclear what comes off
- aria-live="polite" on the counter: it changes from the user's own actions, not from a page change
- the reset button kept at a distance from the chips — placed next to them it gets pressed by momentum
- a real empty state instead of a vanishing row: a disappearing block reads as a breakage
- the <style> block inside the component — it holds the palette, the chips and the reset styling

## 6. You may change
- the chips array: groups, values and their order
- the total counter text above the row
- the resetLabel button caption
- the onChange handler: it receives the remaining set of conditions
- the accent through the accent prop — it colours the hovered cross and the reset

## 7. Rules
- The component filters nothing: it shows the set of conditions while the caller rebuilds the results in onChange.
- The reset appears from two chips. On a single condition it duplicates the cross and only gets in the way.
- Shorten long values upstream: the chip row is sized for short captions.
- 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/filters-002.json
https://vibeui.ru/r/filters-002.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-filters-002-*. Клиентский: "use client" ради снятия условий. Фишка показывает группу и значение вместе, а подпись кнопки удаления называет условие целиком, а не номер. Счётчик найденного стоит в aria-live="polite": он меняется от действий пользователя. Кнопка «сбросить всё» появляется от двух фишек — на одной она дублирует крестик.

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 Filters002Chip = {
  id: string
  group: string
  value: string
}

export type Filters002Props = Omit<
  ComponentPropsWithoutRef<"div">,
  "children" | "onChange"
> & {
  chips?: Filters002Chip[]
  total?: string
  resetLabel?: string
  onChange?: (chips: Filters002Chip[]) => void
  accent?: string
}

// Идея компонента: строка того, что уже включено. Фильтры почти всегда
// прячутся в панели, и через минуту непонятно, почему список такой короткий.
// Здесь каждое условие — отдельная фишка с названием группы («Цена: до 5000»),
// а не голое значение: «до 5000» само по себе ничего не значит. Снять условие
// можно поштучно, а «сбросить всё» стоит отдельно и появляется от двух фишек.
const STYLES = `
:where([data-vibeui-block="filters-002"]){
--vibeui-filters-002-surface:oklch(1 0 0);
--vibeui-filters-002-chip:oklch(0.97 0.004 265);
--vibeui-filters-002-fg:oklch(0.23 0.014 265);
--vibeui-filters-002-muted:oklch(0.55 0.014 265);
--vibeui-filters-002-border:oklch(0.89 0.008 265);
--vibeui-filters-002-shell:oklch(0.91 0.006 265);
--vibeui-filters-002-accent:oklch(0.53 0.18 268);
--vibeui-filters-002-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
/* Своя светлая подложка: строку показывают поверх любого фона. */
[data-vibeui-block="filters-002"]{
display:flex;flex-direction:column;gap:0.5rem;
width:100%;max-width:32rem;box-sizing:border-box;padding:0.875rem;
background:var(--vibeui-filters-002-surface);
border:1px solid var(--vibeui-filters-002-shell);border-radius:0.875rem;
font-family:var(--vibeui-filters-002-font);color:var(--vibeui-filters-002-fg);
}
[data-vibeui-block="filters-002"] *{box-sizing:border-box}
[data-vibeui-block="filters-002"] [data-part="head"]{
display:flex;align-items:baseline;justify-content:space-between;gap:0.75rem;
}
[data-vibeui-block="filters-002"] h3{margin:0;font-size:0.8125rem;font-weight:650}
[data-vibeui-block="filters-002"] [data-part="total"]{
margin:0;font-size:0.75rem;color:var(--vibeui-filters-002-muted);
font-variant-numeric:tabular-nums;
}
[data-vibeui-block="filters-002"] ul{
display:flex;flex-wrap:wrap;gap:0.375rem;margin:0;padding:0;list-style:none;
}
/* Фишка называет группу: «до 5000» без «Цена» ничего не значит. */
[data-vibeui-block="filters-002"] [data-part="chip"]{
display:inline-flex;align-items:center;gap:0.375rem;
padding:0.25rem 0.25rem 0.25rem 0.5625rem;border-radius:9999px;
background:var(--vibeui-filters-002-chip);
border:1px solid var(--vibeui-filters-002-border);
font-size:0.75rem;line-height:1.35;
}
[data-vibeui-block="filters-002"] [data-part="group"]{color:var(--vibeui-filters-002-muted)}
[data-vibeui-block="filters-002"] [data-part="value"]{font-weight:650}
[data-vibeui-block="filters-002"] [data-part="chip"] button{
appearance:none;cursor:pointer;flex:none;
display:grid;place-items:center;
width:1.125rem;height:1.125rem;border-radius:9999px;border:0;
background:oklch(1 0 0);color:var(--vibeui-filters-002-muted);
font:inherit;font-size:0.75rem;line-height:1;
transition:background-color .16s ease,color .16s ease;
}
[data-vibeui-block="filters-002"] [data-part="chip"] button:hover{
background:var(--vibeui-filters-002-accent);color:oklch(1 0 0);
}
[data-vibeui-block="filters-002"] [data-part="chip"] button:focus-visible{
outline:2px solid var(--vibeui-filters-002-accent);outline-offset:2px;
}
/* «Сбросить всё» отделено: рядом с фишками его нажимают по инерции. */
[data-vibeui-block="filters-002"] [data-part="reset"]{
appearance:none;cursor:pointer;align-self:flex-start;
padding:0.25rem 0.625rem;border-radius:9999px;
border:1px dashed var(--vibeui-filters-002-border);
background:none;color:var(--vibeui-filters-002-accent);
font:inherit;font-size:0.75rem;font-weight:650;
}
[data-vibeui-block="filters-002"] [data-part="reset"]:hover{border-style:solid;border-color:var(--vibeui-filters-002-accent)}
[data-vibeui-block="filters-002"] [data-part="reset"]:focus-visible{outline:2px solid var(--vibeui-filters-002-accent);outline-offset:2px}
[data-vibeui-block="filters-002"] [data-part="empty"]{
margin:0;font-size:0.8125rem;color:var(--vibeui-filters-002-muted);
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="filters-002"] *{animation:none!important;transition:none!important}}
`

const DEFAULT_CHIPS: Filters002Chip[] = [
  { id: "1", group: "Категория", value: "Формы" },
  { id: "2", group: "Цена", value: "до 5000 ₽" },
  { id: "3", group: "Лицензия", value: "MIT" },
  { id: "4", group: "Обновлён", value: "за месяц" },
]

/**
 * Строка активных фильтров: снятие по одному и отдельный сброс всего набора.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Filters002({
  chips = DEFAULT_CHIPS,
  total = "Найдено 128 компонентов",
  resetLabel = "Сбросить всё",
  onChange,
  accent,
  className,
  style,
  ...props
}: Filters002Props) {
  const [list, setList] = useState(chips)

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

  const apply = (next: Filters002Chip[]) => {
    setList(next)
    onChange?.(next)
  }

  return (
    <>
      <style href="vibeui-filters-002" precedence="medium">
        {STYLES}
      </style>
      <div
        {...props}
        data-vibeui-block="filters-002"
        className={className}
        style={palette}
      >
        <div data-part="head">
          <h3>Активные фильтры</h3>
          <p data-part="total" aria-live="polite">
            {total}
          </p>
        </div>

        {list.length === 0 ? (
          <p data-part="empty">Фильтров нет — показан весь каталог целиком.</p>
        ) : (
          <ul>
            {list.map((chip) => (
              <li key={chip.id} data-part="chip">
                <span data-part="group">{chip.group}:</span>
                <span data-part="value">{chip.value}</span>
                <button
                  type="button"
                  aria-label={`Снять фильтр ${chip.group}: ${chip.value}`}
                  onClick={() =>
                    apply(list.filter((item) => item.id !== chip.id))
                  }
                >
                  ×
                </button>
              </li>
            ))}
          </ul>
        )}

        {/* Сброс появляется от двух фишек: на одной он дублирует крестик. */}
        {list.length > 1 ? (
          <button type="button" data-part="reset" onClick={() => apply([])}>
            {resetLabel}
          </button>
        ) : null}
      </div>
    </>
  )
}