Inputs
Date Presets
A period picked in words: "last 7 days" and "this quarter" come first, and the date pair only appears under "custom range" — in pure CSS.
- filters
- date
- presets
- period
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/filters-005?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 "filters-005" (Date Presets) 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-005.json
Registry item: https://vibeui.ru/r/filters-005.json
Installs to: components/vibeui/filters-005.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 period picked in words: "last 7 days" and "this quarter" come first, and the date pair only appears under "custom range" — in pure CSS.
A date filter: ready-made periods as radio buttons and a pair of date fields that unfolds only under "custom range". The :has selector drives it, with no state. A server component, zero dependencies, one file, its own palette.
## 3. How to use it
import { Filters005 } from "@/components/vibeui/filters-005"
<Filters005
title="Period"
presets={["Today", "Last 7 days", "Last 30 days"]}
/>
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-005-* palette — do not swap it for your theme tokens (bg-accent, border-input and the like)
- the presets ahead of the calendar: "last 7 days" and "this quarter" cover almost every report
- unfolding the date pair through :has on data-choice — that is what keeps the component server-side and state-free
- radio buttons rather than checkboxes: one period is chosen, and the markup has to say so
- the <fieldset> with a <legend>: the list of periods is a group, not a set of independent rows
- aria-labels on the date fields: bare "start" and "end" do not read without the period name
- the <style> block inside the component — it holds the palette, the radios and the unfolding rule
## 6. You may change
- the title and the presets array of your own periods
- the customLabel caption for the custom range option
- the name prop: the form field names are built from it
- the accent through the accent prop — it colours the chosen option
- the explanation under the list
## 7. Rules
- Presets are captions, not dates: the server computes the bounds, otherwise the client time zone skews the report.
- The "start not after end" check belongs to the caller: native date fields do not do it.
- The :has selector drives the unfolding — in very old browsers the date pair is always visible.
- 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-005.jsonhttps://vibeui.ru/r/filters-005.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-filters-005-*. Серверный: пресеты — радиокнопки внутри <fieldset> с <legend>, а пара дат показывается селектором :has по отмеченной радиокнопке с data-choice="custom". Состояния нет, поэтому пустые поля дат не мешают и не уезжают в форму без надобности. Радиокнопки нарисованы через appearance:none толщиной бордюра.
Component source
The same file your agent installs. Here in case you would rather copy it by hand.
import type { ComponentPropsWithoutRef, CSSProperties } from "react"
export type Filters005Props = Omit<
ComponentPropsWithoutRef<"div">,
"children" | "defaultValue"
> & {
title?: string
presets?: string[]
customLabel?: string
name?: string
accent?: string
}
// Идея компонента: период выбирают словами, а календарём — в последнюю
// очередь. «За 7 дней» и «этот месяц» закрывают почти все отчёты, поэтому
// они стоят первыми, а пара дат появляется только под пунктом «свой период».
// Раскрытие держит селектор :has по отмеченной радиокнопке — состояния нет,
// компонент серверный, и пустые поля дат не уезжают в форму без надобности.
const STYLES = `
:where([data-vibeui-block="filters-005"]){
--vibeui-filters-005-surface:oklch(1 0 0);
--vibeui-filters-005-fill:oklch(0.975 0.004 265);
--vibeui-filters-005-fg:oklch(0.23 0.014 265);
--vibeui-filters-005-muted:oklch(0.55 0.014 265);
--vibeui-filters-005-border:oklch(0.89 0.008 265);
--vibeui-filters-005-shell:oklch(0.91 0.006 265);
--vibeui-filters-005-accent:oklch(0.52 0.19 290);
--vibeui-filters-005-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
/* Своя светлая подложка: фильтр показывают поверх любого фона. */
[data-vibeui-block="filters-005"]{
display:flex;flex-direction:column;gap:0.5rem;
width:100%;max-width:19rem;box-sizing:border-box;padding:0.875rem;
background:var(--vibeui-filters-005-surface);
border:1px solid var(--vibeui-filters-005-shell);border-radius:0.875rem;
font-family:var(--vibeui-filters-005-font);color:var(--vibeui-filters-005-fg);
}
[data-vibeui-block="filters-005"] *{box-sizing:border-box}
[data-vibeui-block="filters-005"] fieldset{margin:0;padding:0;border:0;min-inline-size:0}
[data-vibeui-block="filters-005"] legend{
padding:0;margin-bottom:0.5rem;font-size:0.8125rem;font-weight:650;
}
[data-vibeui-block="filters-005"] [data-part="list"]{
display:flex;flex-direction:column;gap:0.125rem;
}
[data-vibeui-block="filters-005"] label{
display:flex;align-items:center;gap:0.5rem;cursor:pointer;
padding:0.3125rem 0.5rem;border-radius:0.5rem;
font-size:0.8125rem;
transition:background-color .16s ease;
}
[data-vibeui-block="filters-005"] label:hover{background:var(--vibeui-filters-005-fill)}
[data-vibeui-block="filters-005"] label:has(input:checked){
background:color-mix(in oklab,var(--vibeui-filters-005-accent) 9%,oklch(1 0 0));
font-weight:650;
}
[data-vibeui-block="filters-005"] label:has(input:focus-visible){outline:2px solid var(--vibeui-filters-005-accent);outline-offset:1px}
[data-vibeui-block="filters-005"] input[type="radio"]{
appearance:none;flex:none;margin:0;cursor:pointer;position:relative;
width:0.9375rem;height:0.9375rem;border-radius:9999px;
border:1.5px solid var(--vibeui-filters-005-border);background:oklch(1 0 0);
transition:border-color .16s ease;
}
[data-vibeui-block="filters-005"] input[type="radio"]:checked{border-color:var(--vibeui-filters-005-accent);border-width:5px}
/* Пара дат появляется только под «своим периодом»: :has, а не состояние. */
[data-vibeui-block="filters-005"] [data-part="custom"]{display:none;gap:0.375rem;margin-top:0.375rem}
[data-vibeui-block="filters-005"]:has([data-choice="custom"]:checked) [data-part="custom"]{display:flex}
[data-vibeui-block="filters-005"] [data-part="cell"]{
flex:1;min-width:0;display:flex;flex-direction:column;gap:0.125rem;
}
[data-vibeui-block="filters-005"] [data-part="cell"] span{
font-size:0.625rem;font-weight:650;color:var(--vibeui-filters-005-muted);
}
[data-vibeui-block="filters-005"] input[type="date"]{
width:100%;min-width:0;height:2.125rem;padding:0 0.5rem;
background:var(--vibeui-filters-005-surface);color:inherit;
border:1px solid var(--vibeui-filters-005-border);border-radius:0.5rem;
font:inherit;font-size:0.75rem;
}
[data-vibeui-block="filters-005"] input[type="date"]:focus-visible{
outline:2px solid var(--vibeui-filters-005-accent);outline-offset:1px;
border-color:var(--vibeui-filters-005-accent);
}
[data-vibeui-block="filters-005"] [data-part="note"]{
margin:0;padding-top:0.125rem;
font-size:0.6875rem;line-height:1.4;color:var(--vibeui-filters-005-muted);
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="filters-005"] *{animation:none!important;transition:none!important}}
`
const DEFAULT_PRESETS = ["Сегодня", "За 7 дней", "За 30 дней", "Этот квартал"]
/**
* Фильтр по датам: пресеты периодов и пара дат под «своим периодом» на :has.
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Filters005({
title = "Период",
presets = DEFAULT_PRESETS,
customLabel = "Свой период",
name = "period",
accent,
className,
style,
...props
}: Filters005Props) {
const palette = {
...(accent ? { "--vibeui-filters-005-accent": accent } : null),
...style,
} as CSSProperties
return (
<>
<style href="vibeui-filters-005" precedence="medium">
{STYLES}
</style>
<div
{...props}
data-vibeui-block="filters-005"
className={className}
style={palette}
>
<fieldset>
<legend>{title}</legend>
<div data-part="list">
{presets.map((preset, index) => (
<label key={preset}>
<input
type="radio"
name={name}
value={preset}
defaultChecked={index === 1}
/>
{preset}
</label>
))}
<label>
<input
type="radio"
name={name}
value="custom"
data-choice="custom"
/>
{customLabel}
</label>
</div>
<div data-part="custom">
<span data-part="cell">
<span>Начало</span>
<input
type="date"
name={`${name}-from`}
aria-label="Начало периода"
/>
</span>
<span data-part="cell">
<span>Конец</span>
<input
type="date"
name={`${name}-to`}
aria-label="Конец периода"
/>
</span>
</div>
</fieldset>
<p data-part="note">
Период считается по вашему часовому поясу, границы включаются целиком.
</p>
</div>
</>
)
}