Checkbox
Filter Chips
A compact wrapping row of filter chips: real checkboxes with a hidden input, a tick on the selected ones and a reset.
- checkbox
- chips
- filters
- compact
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/checkbox-019?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 "checkbox-019" (Filter 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/checkbox-019.json
Registry item: https://vibeui.ru/r/checkbox-019.json
Installs to: components/vibeui/checkbox-019.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 compact wrapping row of filter chips: real checkboxes with a hidden input, a tick on the selected ones and a reset.
A row of filter chips that wraps: every chip is a real checkbox, a selected one fills in and gains a tick. A reset button and a counter sit alongside. Zero dependencies, one file.
## 3. How to use it
import { Checkbox019 } from "@/components/vibeui/checkbox-019"
<Checkbox019
legend="Quick filters"
options={filters}
defaultValue={["In stock"]}
onChange={setFilters}
/>
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-checkbox-019-* palette — do not swap it for your theme tokens
- the real inputs inside the chips: without them these are buttons a screen reader never calls checked
- the tick on a selected chip — fill alone cannot carry the state for colour-blind users
- growing the tick by width rather than opacity: otherwise an unselected chip reserves blank space
- the wrapping (flex-wrap): a filter row must not run off the edge on a phone
- the reset button disabled on an empty selection, and the counter beside it
## 6. You may change
- the options array and the initial defaultValue
- legend — the filter group's name
- the onChange handler
- the accent through the accent prop — the selected chip colour
## 7. Rules
- Chips work up to about ten: beyond that the row wraps three times and loses to a list.
- The component filters nothing itself: it hands the selected values to onChange.
- Long captions break the compactness — keep them to two or three words.
- 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/checkbox-019.jsonhttps://vibeui.ru/r/checkbox-019.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-checkbox-019-*. Клиентский: "use client". Таблетка — label со спрятанным input (clip-path: inset(50%)), состояние берётся через :has(input:checked). Галочка появляется анимацией ширины, а не opacity, поэтому невыбранная таблетка не резервирует пустое место. Группа обёрнута в fieldset с legend, кнопка сброса выключена при пустом выборе.
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 Checkbox019Props = Omit<
ComponentPropsWithoutRef<"fieldset">,
"children" | "onChange"
> & {
legend?: string
options?: string[]
defaultValue?: string[]
onChange?: (value: string[]) => void
accent?: string
}
// Идея компонента: фильтры-таблетки в одну ленту с переносом. Каждая
// таблетка — настоящий чекбокс со спрятанным input, поэтому Tab и пробел
// работают, а внешне это компактный ряд, помещающийся над списком. Отмеченная
// таблетка не только заливается, но и получает галочку слева: заливка одна
// не читается при дальтонизме.
const STYLES = `
:where([data-vibeui-block="checkbox-019"]){
--vibeui-checkbox-019-bg:oklch(1 0 0);
--vibeui-checkbox-019-fg:oklch(0.24 0.014 265);
--vibeui-checkbox-019-muted:oklch(0.55 0.014 265);
--vibeui-checkbox-019-border:oklch(0.89 0.006 265);
--vibeui-checkbox-019-chip:oklch(0.97 0.003 265);
--vibeui-checkbox-019-accent:oklch(0.45 0.13 200);
--vibeui-checkbox-019-on:oklch(0.98 0.01 200);
--vibeui-checkbox-019-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="checkbox-019"]{
display:flex;flex-wrap:wrap;align-items:center;gap:0.375rem;
width:100%;max-width:26rem;box-sizing:border-box;
margin:0;padding:0.75rem;border:1px solid var(--vibeui-checkbox-019-border);border-radius:0.875rem;
background:var(--vibeui-checkbox-019-bg);
font-family:var(--vibeui-checkbox-019-font);color:var(--vibeui-checkbox-019-fg);
}
[data-vibeui-block="checkbox-019"] legend{float:left;width:100%;padding:0 0 0.5rem;font-size:0.75rem;font-weight:650;color:var(--vibeui-checkbox-019-muted);text-transform:uppercase;letter-spacing:0.04em}
[data-vibeui-block="checkbox-019"] label{
clear:both;display:inline-flex;align-items:center;gap:0.25rem;
height:1.875rem;padding:0 0.625rem;border-radius:9999px;cursor:pointer;
background:var(--vibeui-checkbox-019-chip);
box-shadow:inset 0 0 0 1px var(--vibeui-checkbox-019-border);
font-size:0.8125rem;line-height:1;white-space:nowrap;
transition:background-color .15s ease,color .15s ease,box-shadow .15s ease;
}
[data-vibeui-block="checkbox-019"] label:hover{box-shadow:inset 0 0 0 1px var(--vibeui-checkbox-019-accent)}
[data-vibeui-block="checkbox-019"] label:has(input:checked){
background:var(--vibeui-checkbox-019-accent);color:var(--vibeui-checkbox-019-on);
box-shadow:none;font-weight:600;
}
[data-vibeui-block="checkbox-019"] label:has(input:focus-visible){outline:2px solid var(--vibeui-checkbox-019-accent);outline-offset:2px}
[data-vibeui-block="checkbox-019"] input{
appearance:none;position:absolute;width:1px;height:1px;margin:0;padding:0;
overflow:hidden;clip-path:inset(50%);white-space:nowrap;
}
/* Галочка появляется шириной, а не opacity: невыбранная таблетка не тащит
за собой пустое место под значок. */
[data-vibeui-block="checkbox-019"] [data-part="tick"]{
display:inline-block;width:0;height:0.5rem;overflow:hidden;
transition:width .15s ease,margin .15s ease;
}
[data-vibeui-block="checkbox-019"] label:has(input:checked) [data-part="tick"]{
width:0.3125rem;margin-right:0.1875rem;
border-right:2px solid currentColor;border-bottom:2px solid currentColor;
height:0.5rem;transform:rotate(45deg) translateY(-1px);
}
[data-vibeui-block="checkbox-019"] button{
appearance:none;border:0;background:transparent;cursor:pointer;padding:0 0.25rem;
font:inherit;font-size:0.75rem;font-weight:650;color:var(--vibeui-checkbox-019-accent);
}
[data-vibeui-block="checkbox-019"] button:disabled{color:var(--vibeui-checkbox-019-muted);cursor:not-allowed}
[data-vibeui-block="checkbox-019"] button:focus-visible{outline:2px solid var(--vibeui-checkbox-019-accent);outline-offset:2px;border-radius:0.25rem}
[data-vibeui-block="checkbox-019"] [data-part="count"]{
flex:1 1 100%;margin:0.25rem 0 0;font-size:0.75rem;color:var(--vibeui-checkbox-019-muted);
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="checkbox-019"] *{animation:none!important;transition:none!important}}
`
const DEFAULT_OPTIONS = [
"Бесплатно",
"Со скидкой",
"Новинки",
"В наличии",
"С доставкой",
"Отзывы 4+",
]
/**
* Компактный ряд фильтров-таблеток: настоящие чекбоксы со спрятанным input,
* галочка у отмеченных и сброс. Один файл, ноль зависимостей.
*/
export function Checkbox019({
legend = "Быстрые фильтры",
options = DEFAULT_OPTIONS,
defaultValue = ["В наличии"],
onChange,
accent,
className,
style,
...props
}: Checkbox019Props) {
const [value, setValue] = useState<string[]>(defaultValue)
const palette = {
...(accent ? { "--vibeui-checkbox-019-accent": accent } : null),
...style,
} as CSSProperties
const update = (next: string[]) => {
setValue(next)
onChange?.(next)
}
return (
<>
<style href="vibeui-checkbox-019" precedence="medium">
{STYLES}
</style>
<fieldset
{...props}
data-vibeui-block="checkbox-019"
className={className}
style={palette}
>
<legend>{legend}</legend>
{options.map((option) => (
<label key={option}>
<input
type="checkbox"
checked={value.includes(option)}
onChange={() =>
update(
value.includes(option)
? value.filter((item) => item !== option)
: [...value, option],
)
}
/>
<span data-part="tick" aria-hidden="true" />
<span>{option}</span>
</label>
))}
<button
type="button"
disabled={value.length === 0}
onClick={() => update([])}
>
Сбросить
</button>
<p data-part="count" role="status">
{value.length === 0
? "Фильтры не выбраны"
: `Выбрано фильтров: ${value.length}`}
</p>
</fieldset>
</>
)
}