Inputs
Quarter Hour Slots
Time on a quarter-hour grid: whatever is typed snaps to the nearest quarter, and the buttons move by one step.
- time
- slots
- booking
- step
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/date-008?lang=en
Шаг 15 минприём с 09:00 до 20:00
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 "date-008" (Quarter Hour Slots) 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/date-008.json
Registry item: https://vibeui.ru/r/date-008.json
Installs to: components/vibeui/date-008.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
Time on a quarter-hour grid: whatever is typed snaps to the nearest quarter, and the buttons move by one step.
A time field on a quarter-hour grid: buttons shift and snap, manual input rounds on blur. Zero dependencies, one file.
## 3. How to use it
import { Date008 } from "@/components/vibeui/date-008"
<Date008 label="Appointment time" defaultValue="14:30" stepMinutes={15} openAt="09:00" closeAt="20:00" />
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-date-008-* palette — do not swap it for your theme tokens
- its own light surface: the field gets shown over any background
- converting time to minutes past midnight: shifting and snapping become arithmetic instead of string surgery
- snapping on blur rather than on every keystroke: otherwise the field jumps while you are still typing
- snapping on shift: from 14:07 the button has to give 14:15, not 14:22
- disabling the buttons at the opening bounds instead of silently bumping into them
- the aria-label carrying the step size: "−15" alone reads as a bare number
## 6. You may change
- label — the field caption
- defaultValue — the starting time
- stepMinutes — the grid size, half an hour works the same
- openAt and closeAt — the opening bounds
- the accent through the accent prop
## 7. Rules
- The step attribute is in seconds: 15 minutes is 900, otherwise the browser rejects off-grid values.
- The bounds do not cross midnight: a night shift needs two intervals.
- The component knows nothing about taken slots: filter them out before submitting.
- 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/date-008.jsonhttps://vibeui.ru/r/date-008.jsonКомпонент самодостаточен: один файл, ноль зависимостей, палитра в локальных переменных --vibeui-date-008-*. Клиентский: время в состоянии, кнопки и округление меняют его. Время переводится в минуты от полуночи — так сдвиг и выравнивание по сетке становятся обычной арифметикой, без разбора строк на каждом шаге. Округление к ближайшей четверти делается по blur, а не на каждое нажатие, иначе поле начнёт прыгать во время набора. Границы приёма заданы через min и max и учитываются и кнопками, и клавиатурой.
Component source
The same file your agent installs. Here in case you would rather copy it by hand.
"use client"
import { useId, useState } from "react"
import type { ComponentPropsWithoutRef, CSSProperties } from "react"
export type Date008Props = Omit<
ComponentPropsWithoutRef<"div">,
"children" | "defaultValue"
> & {
label?: string
defaultValue?: string
stepMinutes?: number
openAt?: string
closeAt?: string
accent?: string
}
// Идея компонента: время по сетке в четверть часа. Запись «на 14:07» не нужна
// никому, но нативное поле её позволяет, поэтому любое введённое значение
// округляется до ближайшей четверти. Кнопки сдвигают время на шаг и заодно
// выравнивают по сетке: сдвиг от 14:07 даёт 14:15, а не 14:22. Границы работы
// заданы через min и max, и за них не выйдут ни кнопки, ни клавиатура.
const STYLES = `
:where([data-vibeui-block="date-008"]){
--vibeui-date-008-surface:oklch(1 0 0);
--vibeui-date-008-field:oklch(0.985 0.002 265);
--vibeui-date-008-shell:oklch(0.9 0.006 265);
--vibeui-date-008-fg:oklch(0.23 0.014 265);
--vibeui-date-008-muted:oklch(0.55 0.014 265);
--vibeui-date-008-border:oklch(0.88 0.008 265);
--vibeui-date-008-accent:oklch(0.5 0.15 240);
--vibeui-date-008-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
/* Своя светлая подложка: поле показывают поверх любого фона. */
[data-vibeui-block="date-008"]{
display:flex;flex-direction:column;gap:0.5rem;
width:100%;max-width:19rem;box-sizing:border-box;padding:0.875rem;
background:var(--vibeui-date-008-surface);
border:1px solid var(--vibeui-date-008-shell);border-radius:0.875rem;
font-family:var(--vibeui-date-008-font);color:var(--vibeui-date-008-fg);
}
[data-vibeui-block="date-008"] label{font-size:0.8125rem;font-weight:650}
[data-vibeui-block="date-008"] [data-part="row"]{display:flex;align-items:stretch;gap:0.375rem}
[data-vibeui-block="date-008"] input{
flex:1 1 auto;min-width:0;box-sizing:border-box;
height:2.75rem;padding:0 0.75rem;text-align:center;
background:var(--vibeui-date-008-field);color:inherit;
border:1px solid var(--vibeui-date-008-border);border-radius:0.625rem;
font:inherit;font-size:1.125rem;font-weight:700;font-variant-numeric:tabular-nums;
}
[data-vibeui-block="date-008"] input:focus-visible{
outline:2px solid var(--vibeui-date-008-accent);outline-offset:1px;border-color:var(--vibeui-date-008-accent);
}
[data-vibeui-block="date-008"] input::-webkit-calendar-picker-indicator{display:none}
/* Кнопки сдвигают на шаг и заодно выравнивают по сетке. */
[data-vibeui-block="date-008"] button{
appearance:none;cursor:pointer;flex:none;
width:2.75rem;height:2.75rem;
border:1px solid var(--vibeui-date-008-border);border-radius:0.625rem;
background:var(--vibeui-date-008-surface);color:inherit;
font:inherit;font-size:0.6875rem;font-weight:700;line-height:1.1;
transition:border-color .14s ease,color .14s ease;
}
[data-vibeui-block="date-008"] button:hover:not(:disabled){border-color:var(--vibeui-date-008-accent);color:var(--vibeui-date-008-accent)}
[data-vibeui-block="date-008"] button:focus-visible{outline:2px solid var(--vibeui-date-008-accent);outline-offset:2px}
[data-vibeui-block="date-008"] button:disabled{opacity:.4;cursor:default}
[data-vibeui-block="date-008"] [data-part="hint"]{
display:flex;justify-content:space-between;gap:0.75rem;margin:0;
font-size:0.75rem;color:var(--vibeui-date-008-muted);font-variant-numeric:tabular-nums;
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="date-008"] *{animation:none!important;transition:none!important}}
`
function toMinutes(value: string) {
const [hours, minutes] = value.split(":").map(Number)
if (!Number.isFinite(hours) || !Number.isFinite(minutes)) return 0
return hours * 60 + minutes
}
function toTime(minutes: number) {
const hours = Math.floor(minutes / 60) % 24
return `${String(hours).padStart(2, "0")}:${String(minutes % 60).padStart(2, "0")}`
}
/**
* Поле времени с сеткой в четверть часа и кнопками сдвига по шагу.
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Date008({
label = "Время записи",
defaultValue = "14:30",
stepMinutes = 15,
openAt = "09:00",
closeAt = "20:00",
accent,
className,
style,
...props
}: Date008Props) {
const id = useId()
const [value, setValue] = useState(defaultValue)
const open = toMinutes(openAt)
const close = toMinutes(closeAt)
const current = toMinutes(value)
// Округление к ближайшей четверти: «на 14:07» не записывают никого.
const snap = (minutes: number) =>
Math.min(
close,
Math.max(open, Math.round(minutes / stepMinutes) * stepMinutes),
)
const palette = {
...(accent ? { "--vibeui-date-008-accent": accent } : null),
...style,
} as CSSProperties
return (
<>
<style href="vibeui-date-008" precedence="medium">
{STYLES}
</style>
<div
{...props}
data-vibeui-block="date-008"
className={className}
style={palette}
>
<label htmlFor={id}>{label}</label>
<div data-part="row">
<button
type="button"
disabled={current <= open}
aria-label={`Раньше на ${stepMinutes} минут`}
onClick={() => setValue(toTime(snap(current - stepMinutes)))}
>
−{stepMinutes}
</button>
<input
id={id}
type="time"
value={value}
min={openAt}
max={closeAt}
step={stepMinutes * 60}
aria-describedby={`${id}-hint`}
onChange={(event) => setValue(event.target.value)}
onBlur={() => setValue(toTime(snap(toMinutes(value))))}
/>
<button
type="button"
disabled={current >= close}
aria-label={`Позже на ${stepMinutes} минут`}
onClick={() => setValue(toTime(snap(current + stepMinutes)))}
>
+{stepMinutes}
</button>
</div>
<p id={`${id}-hint`} data-part="hint">
<span>Шаг {stepMinutes} мин</span>
<span>
приём с {openAt} до {closeAt}
</span>
</p>
</div>
</>
)
}