Button Group
Dated Presets
Period presets with concrete dates under each name: "the last 7 days" and "6–12 May" answer different questions, and the second line removes the trip to a calendar.
- buttongroup
- period
- dates
- analytics
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-046?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-046" (Dated 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/buttongroup-046.json
Registry item: https://vibeui.ru/r/buttongroup-046.json
Installs to: components/vibeui/buttongroup-046.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
Period presets with concrete dates under each name: "the last 7 days" and "6–12 May" answer different questions, and the second line removes the trip to a calendar.
Period presets, each carrying its concrete date range under the name. Zero dependencies, one file, a server component.
## 3. How to use it
import { Buttongroup046 } from "@/components/vibeui/buttongroup-046"
<Buttongroup046
periods={[{ label: "Week", range: "6–12 May" }]}
customLabel="Custom"
defaultValue="Week"
name="period"
/>
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-046-* palette — do not swap it for your theme tokens
- the second line with dates: without it the user goes to a calendar to check
- the equal track columns: otherwise the range lines never form one baseline
- the icon instead of a range on "custom" — an empty line would make that segment shorter
- tabular figures in the dates so "13.04" and "6–12" keep the same width
- the z-index on the selected and focused segment with collapsed borders
## 6. You may change
- the presets and their ranges through periods
- the custom period caption through customLabel
- the initial preset through defaultValue and the group name through label
- the form field name through name and the accent through accent
## 7. Rules
- Dates arrive as ready strings: your code computes them, the component only shows them.
- "Custom" opens no calendar: wire your own date picker at install time.
- More than four presets stop fitting into equal columns on a phone.
- 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-046.jsonhttps://vibeui.ru/r/buttongroup-046.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в переменных --vibeui-buttongroup-046-*. Серверный: выбор держат radio внутри fieldset. Трек — grid с grid-auto-columns:1fr, поэтому строки диапазонов выстраиваются в общую линию, а сегменты остаются целями одного размера. Даты набраны табличными цифрами и не переносятся. Последний сегмент — «Свой период»: у него нет диапазона, и вместо него стоит значок календаря, а не пустая строка, иначе высота сегмента отличалась бы от соседей. Границы схлопнуты через margin-inline-start:-1px, скругления только крайним, выбранный поднят z-index:1, сфокусированный — z-index:2.
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 Buttongroup046Period = {
label: string
range: string
}
export type Buttongroup046Props = Omit<
ComponentPropsWithoutRef<"fieldset">,
"children"
> & {
periods?: Buttongroup046Period[]
customLabel?: string
defaultValue?: string
label?: string
name?: string
accent?: string
}
// Идея компонента: пресеты периода, которые не заставляют считать в уме.
// Под названием каждого сегмента стоит конкретный диапазон дат — «Последние
// 7 дней» и «6–12 мая» отвечают на разные вопросы, и без второй строки
// пользователь идёт сверять с календарём. Даты набраны табличными цифрами,
// сегменты равной ширины (grid 1fr), поэтому строки диапазонов выстраиваются
// в общую линию. Последний сегмент — «Свой период»: у него нет диапазона,
// и вместо него стоит значок календаря, а не пустая строка.
const STYLES = `
:where([data-vibeui-block="buttongroup-046"]){
--vibeui-buttongroup-046-surface:oklch(1 0 0);
--vibeui-buttongroup-046-fg:oklch(0.25 0.016 265);
--vibeui-buttongroup-046-muted:oklch(0.58 0.014 265);
--vibeui-buttongroup-046-border:oklch(0.89 0.008 265);
--vibeui-buttongroup-046-on:oklch(0.965 0.03 265);
--vibeui-buttongroup-046-accent:oklch(0.5 0.16 265);
--vibeui-buttongroup-046-radius:0.75rem;
--vibeui-buttongroup-046-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="buttongroup-046"]{
box-sizing:border-box;display:block;width:100%;max-width:30rem;
margin:0;padding:0;border:0;
font-family:var(--vibeui-buttongroup-046-font);
}
[data-vibeui-block="buttongroup-046"] *{box-sizing:border-box}
[data-vibeui-block="buttongroup-046"] legend{
position:absolute;width:1px;height:1px;padding:0;margin:-1px;
overflow:hidden;clip-path:inset(50%);white-space:nowrap;
}
[data-vibeui-block="buttongroup-046"] [data-part="track"]{
display:grid;grid-auto-flow:column;grid-auto-columns:1fr;isolation:isolate;
}
[data-vibeui-block="buttongroup-046"] [data-part="segment"]{
position:relative;z-index:0;
display:flex;flex-direction:column;align-items:center;justify-content:center;gap:0.1875rem;
min-height:3.375rem;padding:0.5rem 0.375rem;margin-inline-start:-1px;
border:1px solid var(--vibeui-buttongroup-046-border);
background:var(--vibeui-buttongroup-046-surface);
cursor:pointer;text-align:center;
transition:background-color .16s ease,border-color .16s ease;
}
[data-vibeui-block="buttongroup-046"] [data-part="segment"]:first-child{
margin-inline-start:0;
border-start-start-radius:var(--vibeui-buttongroup-046-radius);
border-end-start-radius:var(--vibeui-buttongroup-046-radius);
}
[data-vibeui-block="buttongroup-046"] [data-part="segment"]:last-child{
border-start-end-radius:var(--vibeui-buttongroup-046-radius);
border-end-end-radius:var(--vibeui-buttongroup-046-radius);
}
[data-vibeui-block="buttongroup-046"] input{
position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:pointer;
}
[data-vibeui-block="buttongroup-046"] [data-part="name"]{
color:var(--vibeui-buttongroup-046-fg);
font-size:0.75rem;font-weight:650;line-height:1.2;
}
[data-vibeui-block="buttongroup-046"] [data-part="range"]{
color:var(--vibeui-buttongroup-046-muted);
font-size:0.6875rem;line-height:1.2;
font-variant-numeric:tabular-nums;white-space:nowrap;
}
[data-vibeui-block="buttongroup-046"] svg{
width:0.875rem;height:0.875rem;
stroke:var(--vibeui-buttongroup-046-muted);fill:none;stroke-width:1.8;
stroke-linecap:round;stroke-linejoin:round;
}
[data-vibeui-block="buttongroup-046"] [data-part="segment"]:hover{background:oklch(0.985 0.003 265)}
[data-vibeui-block="buttongroup-046"] [data-part="segment"]:has(input:checked){
z-index:1;
background:var(--vibeui-buttongroup-046-on);
border-color:var(--vibeui-buttongroup-046-accent);
}
[data-vibeui-block="buttongroup-046"] [data-part="segment"]:has(input:checked) [data-part="name"]{
color:var(--vibeui-buttongroup-046-accent);
}
[data-vibeui-block="buttongroup-046"] [data-part="segment"]:has(input:focus-visible){
z-index:2;outline:2px solid var(--vibeui-buttongroup-046-accent);outline-offset:1px;
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="buttongroup-046"] *{animation:none!important;transition:none!important}}
`
const DEFAULT_PERIODS: Buttongroup046Period[] = [
{ label: "Неделя", range: "6–12 мая" },
{ label: "Месяц", range: "13.04 – 12.05" },
{ label: "Квартал", range: "13.02 – 12.05" },
]
/**
* Пресеты периода, каждый со своим конкретным диапазоном дат под названием.
* Один файл, ноль зависимостей, серверный компонент.
*/
export function Buttongroup046({
periods = DEFAULT_PERIODS,
customLabel = "Свой период",
defaultValue = "Месяц",
label = "Период отчёта",
name = "buttongroup-046",
accent,
className,
style,
...props
}: Buttongroup046Props) {
const palette = {
...(accent ? { "--vibeui-buttongroup-046-accent": accent } : null),
...style,
} as CSSProperties
return (
<>
<style href="vibeui-buttongroup-046" precedence="medium">
{STYLES}
</style>
<fieldset
{...props}
data-vibeui-block="buttongroup-046"
className={className}
style={palette}
>
<legend>{label}</legend>
<div data-part="track">
{periods.map((period) => (
<label key={period.label} data-part="segment">
<input
type="radio"
name={name}
value={period.label}
defaultChecked={period.label === defaultValue}
/>
<span data-part="name">{period.label}</span>
<span data-part="range">{period.range}</span>
</label>
))}
<label data-part="segment">
<input
type="radio"
name={name}
value="custom"
defaultChecked={customLabel === defaultValue}
/>
<span data-part="name">{customLabel}</span>
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M4 6h16v14H4zM4 10h16M9 3v4M15 3v4" />
</svg>
</label>
</div>
</fieldset>
</>
)
}