Feedback
Filter Drawer
A filter drawer that applies nothing on its own: choices collect inside and leave with one button, so the list behind it does not rebuild after every checkbox.
- drawer
- filters
- sidebar
- dialog
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/drawer-003?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 "drawer-003" (Filter Drawer) 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/drawer-003.json
Registry item: https://vibeui.ru/r/drawer-003.json
Installs to: components/vibeui/drawer-003.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 drawer that applies nothing on its own: choices collect inside and leave with one button, so the list behind it does not rebuild after every checkbox.
A left-hand filter drawer: checkbox groups with counts, a selected counter on the trigger, a reset in the header and an apply button in the footer. Nothing leaves the drawer until the button is pressed. Zero dependencies, one file, its own palette.
## 3. How to use it
import { Drawer003 } from "@/components/vibeui/drawer-003"
<Drawer003
triggerLabel="Filters"
title="Filters"
groups={groups}
applyLabel="Show results"
/>
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-drawer-003-* palette — do not swap it for your theme tokens
- deferred application: the list behind must not rebuild after every checkbox
- the selected counter on the trigger and on the apply button — otherwise nothing says how many conditions are on
- scrolling the middle area only: the reset header and the apply button have to stay in view
- the counts beside the options: choosing without an expected result count is choosing blind
- the disabled reset when nothing is selected: a button that does nothing lies
## 6. You may change
- title — the drawer heading and its accessible name
- the groups array: group headings, options and their counts
- triggerLabel and applyLabel — the trigger and apply wording
- the drawer width: 20rem holds a single column of options
- the side it slides from — left was chosen because filters usually live at the left edge of a list
## 7. Rules
- The selection lives inside the component: lift the state out in the apply handler to actually filter.
- More than five groups in one drawer stops being readable — fold rare conditions into details.
- On a wide screen filters belong in a column beside the list: a drawer is for where there is no room.
- 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/drawer-003.jsonhttps://vibeui.ru/r/drawer-003.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-drawer-003-*. Клиентский: "use client", useState держит выбранные значения, useRef — showModal и close. Ящик выезжает слева, прокручивается только средняя область (flex + min-height:0), шапка со сбросом и подвал с кнопкой применения стоят на месте. Галочка нарисована псевдоэлементом на appearance:none — иконок нет.
Component source
The same file your agent installs. Here in case you would rather copy it by hand.
"use client"
import { useRef, useState } from "react"
import type { ComponentPropsWithoutRef, CSSProperties } from "react"
export type Drawer003Group = {
title: string
options: { label: string; count: number }[]
}
export type Drawer003Props = Omit<
ComponentPropsWithoutRef<"div">,
"children" | "title"
> & {
triggerLabel?: string
title?: string
groups?: Drawer003Group[]
applyLabel?: string
accent?: string
}
// Идея компонента: боковой ящик фильтров, который ничего не применяет сам.
// Выбор копится внутри и уходит одной кнопкой внизу — так список за спиной
// не перестраивается после каждой галочки. Счётчик выбранного виден на
// кнопке применения и на сбросе: сколько условий сейчас включено.
const STYLES = `
:where([data-vibeui-block="drawer-003"]){
--vibeui-drawer-003-bg:oklch(1 0 0);
--vibeui-drawer-003-fg:oklch(0.21 0.014 265);
--vibeui-drawer-003-muted:oklch(0.55 0.014 265);
--vibeui-drawer-003-border:oklch(0.91 0.006 265);
--vibeui-drawer-003-accent:oklch(0.55 0.17 265);
--vibeui-drawer-003-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="drawer-003"]{
display:inline-block;font-family:var(--vibeui-drawer-003-font);color:var(--vibeui-drawer-003-fg);
}
[data-vibeui-block="drawer-003"] [data-part="trigger"]{
appearance:none;cursor:pointer;
display:inline-flex;align-items:center;gap:0.5rem;
height:2.25rem;padding:0 0.875rem;
border:1px solid var(--vibeui-drawer-003-border);border-radius:0.625rem;
background:var(--vibeui-drawer-003-bg);color:inherit;
font:inherit;font-size:0.8125rem;font-weight:600;
}
[data-vibeui-block="drawer-003"] [data-part="trigger"]:focus-visible{outline:2px solid var(--vibeui-drawer-003-accent);outline-offset:2px}
[data-vibeui-block="drawer-003"] [data-part="badge"]{
display:inline-flex;align-items:center;justify-content:center;
min-width:1.25rem;height:1.25rem;padding:0 0.375rem;border-radius:9999px;
background:var(--vibeui-drawer-003-accent);color:oklch(0.99 0.01 265);
font-size:0.6875rem;font-weight:700;
}
/* Ящик слева: фильтры привычно живут у левого края списка. */
[data-vibeui-block="drawer-003"] dialog{
position:fixed;inset:0 auto 0 0;margin:0;
width:min(20rem,100vw);max-width:100vw;height:100dvh;max-height:100dvh;
padding:0;border:0;background:var(--vibeui-drawer-003-bg);color:inherit;
box-shadow:24px 0 60px -30px oklch(0.2 0.02 265 / 55%);
translate:-100% 0;transition:translate .22s ease,overlay .22s allow-discrete,display .22s allow-discrete;
}
[data-vibeui-block="drawer-003"] dialog[open]{translate:0 0}
@starting-style{
[data-vibeui-block="drawer-003"] dialog[open]{translate:-100% 0}
}
[data-vibeui-block="drawer-003"] dialog::backdrop{background:oklch(0.19 0.02 265 / 45%)}
[data-vibeui-block="drawer-003"] [data-part="panel"]{
display:flex;flex-direction:column;height:100%;box-sizing:border-box;
}
[data-vibeui-block="drawer-003"] [data-part="head"]{
display:flex;align-items:center;justify-content:space-between;gap:0.75rem;
padding:1rem 1rem 0.75rem;border-bottom:1px solid var(--vibeui-drawer-003-border);
}
[data-vibeui-block="drawer-003"] [data-part="title"]{margin:0;font-size:1rem;font-weight:680}
[data-vibeui-block="drawer-003"] [data-part="reset"]{
appearance:none;border:0;background:transparent;cursor:pointer;padding:0;
color:var(--vibeui-drawer-003-accent);font:inherit;font-size:0.8125rem;font-weight:650;
}
[data-vibeui-block="drawer-003"] [data-part="reset"]:disabled{cursor:default;color:var(--vibeui-drawer-003-muted);opacity:.6}
[data-vibeui-block="drawer-003"] [data-part="reset"]:focus-visible{outline:2px solid var(--vibeui-drawer-003-accent);outline-offset:2px;border-radius:0.25rem}
/* Прокручивается только середина: шапка и кнопка применения всегда на месте. */
[data-vibeui-block="drawer-003"] [data-part="body"]{
flex:1;min-height:0;overflow-y:auto;padding:0.25rem 1rem 1rem;
}
[data-vibeui-block="drawer-003"] fieldset{margin:0;padding:0.875rem 0 0;border:0}
[data-vibeui-block="drawer-003"] legend{
padding:0;font-size:0.6875rem;font-weight:700;letter-spacing:0.06em;text-transform:uppercase;
color:var(--vibeui-drawer-003-muted);
}
[data-vibeui-block="drawer-003"] [data-part="option"]{
display:flex;align-items:center;gap:0.625rem;
padding:0.4375rem 0;cursor:pointer;font-size:0.875rem;
}
[data-vibeui-block="drawer-003"] [data-part="option"] input{
appearance:none;flex:none;width:1.125rem;height:1.125rem;margin:0;
border:1.5px solid var(--vibeui-drawer-003-border);border-radius:0.375rem;
background:var(--vibeui-drawer-003-bg);cursor:pointer;position:relative;
}
[data-vibeui-block="drawer-003"] [data-part="option"] input:checked{
background:var(--vibeui-drawer-003-accent);border-color:var(--vibeui-drawer-003-accent);
}
[data-vibeui-block="drawer-003"] [data-part="option"] input:checked::after{
content:"";position:absolute;left:0.3125rem;top:0.125rem;
width:0.25rem;height:0.5rem;border:solid oklch(0.99 0.01 265);
border-width:0 2px 2px 0;transform:rotate(45deg);
}
[data-vibeui-block="drawer-003"] [data-part="option"] input:focus-visible{outline:2px solid var(--vibeui-drawer-003-accent);outline-offset:2px}
[data-vibeui-block="drawer-003"] [data-part="count"]{margin-left:auto;font-size:0.75rem;color:var(--vibeui-drawer-003-muted);font-variant-numeric:tabular-nums}
[data-vibeui-block="drawer-003"] [data-part="foot"]{
padding:0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom,0px));
border-top:1px solid var(--vibeui-drawer-003-border);
}
[data-vibeui-block="drawer-003"] [data-part="apply"]{
appearance:none;border:0;cursor:pointer;width:100%;height:2.75rem;border-radius:0.75rem;
background:var(--vibeui-drawer-003-accent);color:oklch(0.99 0.01 265);
font:inherit;font-size:0.9375rem;font-weight:650;
}
[data-vibeui-block="drawer-003"] [data-part="apply"]:focus-visible{outline:2px solid var(--vibeui-drawer-003-accent);outline-offset:2px}
@media (prefers-reduced-motion:reduce){
[data-vibeui-block="drawer-003"] *{animation:none!important;transition:none!important}
[data-vibeui-block="drawer-003"] dialog{translate:0 0}
}
`
const DEFAULT_GROUPS: Drawer003Group[] = [
{
title: "Категория",
options: [
{ label: "Кнопки", count: 24 },
{ label: "Формы", count: 18 },
{ label: "Таблицы", count: 12 },
],
},
{
title: "Состояние",
options: [
{ label: "Новые", count: 9 },
{ label: "Обновлённые", count: 14 },
],
},
]
/**
* Боковой ящик фильтров: выбор копится внутри и уходит одной кнопкой внизу.
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Drawer003({
triggerLabel = "Фильтры",
title = "Фильтры",
groups = DEFAULT_GROUPS,
applyLabel = "Показать результаты",
accent,
className,
style,
...props
}: Drawer003Props) {
const drawer = useRef<HTMLDialogElement>(null)
const [picked, setPicked] = useState<string[]>([])
const palette = {
...(accent ? { "--vibeui-drawer-003-accent": accent } : null),
...style,
} as CSSProperties
function toggle(label: string) {
setPicked((current) =>
current.includes(label)
? current.filter((item) => item !== label)
: [...current, label],
)
}
return (
<>
<style href="vibeui-drawer-003" precedence="medium">
{STYLES}
</style>
<div
{...props}
data-vibeui-block="drawer-003"
className={className}
style={palette}
>
<button
type="button"
data-part="trigger"
onClick={() => drawer.current?.showModal()}
>
{triggerLabel}
{picked.length ? (
<span data-part="badge" aria-label={`выбрано ${picked.length}`}>
{picked.length}
</span>
) : null}
</button>
<dialog
ref={drawer}
aria-label={title}
onClick={(event) => {
if (event.target === drawer.current) {
drawer.current.close()
}
}}
>
<div data-part="panel">
<div data-part="head">
<h2 data-part="title">{title}</h2>
<button
type="button"
data-part="reset"
disabled={picked.length === 0}
onClick={() => setPicked([])}
>
Сбросить
</button>
</div>
<div data-part="body">
{groups.map((group) => (
<fieldset key={group.title}>
<legend>{group.title}</legend>
{group.options.map((option) => (
<label key={option.label} data-part="option">
<input
type="checkbox"
checked={picked.includes(option.label)}
onChange={() => toggle(option.label)}
/>
<span>{option.label}</span>
<span data-part="count">{option.count}</span>
</label>
))}
</fieldset>
))}
</div>
<div data-part="foot">
<button
type="button"
data-part="apply"
onClick={() => drawer.current?.close()}
>
{applyLabel}
{picked.length ? ` · ${picked.length}` : ""}
</button>
</div>
</div>
</dialog>
</div>
</>
)
}