Button Group
All And Reset
A multi-select filter where "All" is the empty-selection state and the reset on the right stays disabled until there is something to reset.
- buttongroup
- filter
- multi-select
- reset
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/buttongroup-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 "buttongroup-019" (All And Reset) 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/buttongroup-019.json
Registry item: https://vibeui.ru/r/buttongroup-019.json
Installs to: components/vibeui/buttongroup-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 multi-select filter where "All" is the empty-selection state and the reset on the right stays disabled until there is something to reset.
A multi-select filter with "All" on the left and a reset that is disabled until needed. Zero dependencies, one file, a client component.
## 3. How to use it
import { Buttongroup019 } from "@/components/vibeui/buttongroup-019"
<Buttongroup019
options={["Design", "Engineering", "Analytics"]}
allLabel="All"
resetLabel="Reset"
onChange={(list) => setFilters(list)}
/>
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-buttongroup-019-* palette — do not swap it for your theme tokens
- "All" as the empty selection rather than an option of its own: otherwise "all" and "design" end up selected at once
- disabled on the reset while the selection is empty — a live "reset" with nothing to reset is a lie
- the gap between the cluster and the reset: reset is not another filter, and pressed against them it catches misses
- aria-live on the summary line: a silent change of the set tells a blind user nothing
- aria-pressed on the pills, because nothing is submitted and a radio here would be a lie
## 6. You may change
- the set of filters through options
- the empty-selection caption through allLabel
- the reset caption through resetLabel and the accessible group name through label
- the selection callback through onChange and the accent through accent
## 7. Rules
- The component filters nothing: refetching is your onChange handler's job.
- The value never reaches a form: add hidden fields on the page side to submit it.
- More than five filters wrap onto a second line and visually break the cluster.
- 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/buttongroup-019.jsonhttps://vibeui.ru/r/buttongroup-019.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в переменных --vibeui-buttongroup-019-*. Клиентский: useState хранит массив выбранных значений, onChange отдаёт его наружу. Кнопка «Все» не имеет собственного флага — она подсвечена ровно тогда, когда selected.length === 0, и её нажатие очищает набор: так «все» не может одновременно быть выбранным с чем-то ещё. Сброс вынесен за сцепку и получает disabled при пустом выборе, чтобы состояние «изменено / не изменено» читалось без чтения фильтров. Итог объявляется через aria-live="polite". Границы сцепки схлопнуты margin-inline-start:-1px, состояние — на 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 } from "react"
export type Buttongroup019Props = Omit<
ComponentPropsWithoutRef<"div">,
"children" | "onChange"
> & {
options?: string[]
allLabel?: string
resetLabel?: string
label?: string
onChange?: (selected: string[]) => void
accent?: string
}
// Идея компонента: множественный фильтр, у которого «Все» — не отдельный
// вариант, а состояние пустого выбора. Кнопка слева не хранит своего флага:
// она подсвечена ровно тогда, когда не выбрано ничего, и её нажатие
// очищает набор. Сброс справа отделён от сцепки и выключен, пока сбрасывать
// нечего, — так пользователю не приходится гадать, изменил он что-то или нет.
// Итог выбора объявляется через aria-live, иначе изменение молча уезжает.
const STYLES = `
:where([data-vibeui-block="buttongroup-019"]){
--vibeui-buttongroup-019-surface:oklch(1 0 0);
--vibeui-buttongroup-019-fg:oklch(0.26 0.016 265);
--vibeui-buttongroup-019-muted:oklch(0.56 0.014 265);
--vibeui-buttongroup-019-border:oklch(0.89 0.008 265);
--vibeui-buttongroup-019-on:oklch(0.96 0.035 265);
--vibeui-buttongroup-019-accent:oklch(0.53 0.16 265);
--vibeui-buttongroup-019-radius:0.625rem;
--vibeui-buttongroup-019-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="buttongroup-019"]{
box-sizing:border-box;display:flex;flex-direction:column;gap:0.5rem;
width:100%;max-width:30rem;
font-family:var(--vibeui-buttongroup-019-font);
}
[data-vibeui-block="buttongroup-019"] *{box-sizing:border-box}
[data-vibeui-block="buttongroup-019"] [data-part="row"]{
display:flex;align-items:center;gap:0.75rem;flex-wrap:wrap;
}
[data-vibeui-block="buttongroup-019"] [data-part="track"]{display:flex;isolation:isolate}
[data-vibeui-block="buttongroup-019"] [data-part="chip"]{
appearance:none;cursor:pointer;font:inherit;
position:relative;z-index:0;
display:inline-flex;align-items:center;gap:0.375rem;
height:2.25rem;padding:0 0.8125rem;margin-inline-start:-1px;
border:1px solid var(--vibeui-buttongroup-019-border);
background:var(--vibeui-buttongroup-019-surface);
color:var(--vibeui-buttongroup-019-muted);
font-size:0.8125rem;font-weight:600;line-height:1;white-space:nowrap;
transition:background-color .16s ease,color .16s ease,border-color .16s ease;
}
[data-vibeui-block="buttongroup-019"] [data-part="chip"]:first-child{
margin-inline-start:0;
border-start-start-radius:var(--vibeui-buttongroup-019-radius);
border-end-start-radius:var(--vibeui-buttongroup-019-radius);
}
[data-vibeui-block="buttongroup-019"] [data-part="chip"]:last-child{
border-start-end-radius:var(--vibeui-buttongroup-019-radius);
border-end-end-radius:var(--vibeui-buttongroup-019-radius);
}
[data-vibeui-block="buttongroup-019"] [data-part="chip"]:hover{color:var(--vibeui-buttongroup-019-fg)}
[data-vibeui-block="buttongroup-019"] [data-part="chip"][aria-pressed="true"]{
z-index:1;
background:var(--vibeui-buttongroup-019-on);
border-color:var(--vibeui-buttongroup-019-accent);
color:var(--vibeui-buttongroup-019-accent);
}
[data-vibeui-block="buttongroup-019"] [data-part="chip"]:focus-visible{
z-index:2;outline:2px solid var(--vibeui-buttongroup-019-accent);outline-offset:1px;
}
[data-vibeui-block="buttongroup-019"] [data-part="tick"]{
width:0.875rem;height:0.875rem;
stroke:currentColor;fill:none;stroke-width:2.2;
stroke-linecap:round;stroke-linejoin:round;
}
[data-vibeui-block="buttongroup-019"] [data-part="reset"]{
appearance:none;cursor:pointer;font:inherit;
display:inline-flex;align-items:center;gap:0.3125rem;
height:2.25rem;padding:0 0.625rem;margin-inline-start:auto;
border:0;border-radius:var(--vibeui-buttongroup-019-radius);
background:transparent;
color:var(--vibeui-buttongroup-019-muted);
font-size:0.8125rem;font-weight:600;line-height:1;
transition:color .16s ease,background-color .16s ease;
}
[data-vibeui-block="buttongroup-019"] [data-part="reset"]:hover:not(:disabled){
color:var(--vibeui-buttongroup-019-fg);background:oklch(0.96 0.005 265);
}
[data-vibeui-block="buttongroup-019"] [data-part="reset"]:disabled{opacity:.4;cursor:not-allowed}
[data-vibeui-block="buttongroup-019"] [data-part="reset"]:focus-visible{
outline:2px solid var(--vibeui-buttongroup-019-accent);outline-offset:2px;
}
[data-vibeui-block="buttongroup-019"] [data-part="summary"]{
margin:0;color:var(--vibeui-buttongroup-019-muted);
font-size:0.75rem;line-height:1.4;
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="buttongroup-019"] *{animation:none!important;transition:none!important}}
`
const DEFAULT_OPTIONS = ["Дизайн", "Разработка", "Аналитика", "Поддержка"]
/**
* Множественный фильтр, где «Все» — это пустой выбор, а сброс выключен без нужды.
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Buttongroup019({
options = DEFAULT_OPTIONS,
allLabel = "Все",
resetLabel = "Сбросить",
label = "Направления",
onChange,
accent,
className,
style,
...props
}: Buttongroup019Props) {
const [selected, setSelected] = useState<string[]>([])
const apply = (next: string[]) => {
setSelected(next)
onChange?.(next)
}
const palette = {
...(accent ? { "--vibeui-buttongroup-019-accent": accent } : null),
...style,
} as CSSProperties
return (
<>
<style href="vibeui-buttongroup-019" precedence="medium">
{STYLES}
</style>
<div
{...props}
data-vibeui-block="buttongroup-019"
className={className}
style={palette}
>
<div data-part="row">
<div data-part="track" role="group" aria-label={label}>
<button
type="button"
data-part="chip"
aria-pressed={selected.length === 0}
onClick={() => apply([])}
>
{selected.length === 0 ? (
<svg data-part="tick" viewBox="0 0 24 24" aria-hidden="true">
<path d="m5 13 4.5 4.5L19 7" />
</svg>
) : null}
{allLabel}
</button>
{options.map((option) => {
const active = selected.includes(option)
return (
<button
key={option}
type="button"
data-part="chip"
aria-pressed={active}
onClick={() =>
apply(
active
? selected.filter((value) => value !== option)
: [...selected, option],
)
}
>
{option}
</button>
)
})}
</div>
<button
type="button"
data-part="reset"
disabled={selected.length === 0}
onClick={() => apply([])}
>
{resetLabel}
</button>
</div>
<p data-part="summary" aria-live="polite">
{selected.length === 0
? "Показаны все направления"
: `Выбрано направлений: ${selected.length}`}
</p>
</div>
</>
)
}