TimePicker
"use client";
import { Field, TimePicker } from "@cherry-design-system/react";
export function StartTime() {
return (
<Field label="Start time">
<TimePicker name="start" hourCycle={12} min="08:00" max="18:00" fullWidth />
</Field>
);
}A time trigger that opens a popover with a list of time slots or hour and minute columns. Values are "HH:mm" strings on a 24-hour clock, whatever the display. Use DateTimePicker when the day matters too.
Examples
Columns layout
layout="columns" shows hours, minutes and, on a 12-hour clock, AM/PM.
"use client";
import { Field, TimePicker } from "@cherry-design-system/react";
export function Alarm() {
return (
<Field label="Alarm">
<TimePicker layout="columns" hourCycle={12} step={15} />
</Field>
);
}Controlled
"use client";
import { useState } from "react";
import { Field, TimePicker } from "@cherry-design-system/react";
export function Meeting() {
const [time, setTime] = useState<string | null>("09:30");
return (
<Field label="Meeting time" hint={time ? `Stored as ${time}` : undefined}>
<TimePicker value={time} onChange={setTime} hourCycle={24} step={30} />
</Field>
);
}Translated labels
"use client";
import { Field, TimePicker } from "@cherry-design-system/react";
export function Hora() {
return (
<Field label="Hora">
<TimePicker
locale="es-ES"
layout="columns"
placeholder="Elige una hora"
labels={{ dialog: "Elegir hora", hours: "Horas", minutes: "Minutos" }}
/>
</Field>
);
}Properties
Controlled time, "HH:mm" on a 24-hour clock.
Initial time when uncontrolled. Defaults to null.
Called with the picked "HH:mm" value.
Minutes between options. Defaults to 30.
Earliest time, "HH:mm".
Latest time, "HH:mm".
"list": one column of slots. "columns": hours, minutes (and AM/PM). Defaults to "list".
12 or 24-hour clock. Defaults to the locale's.
BCP 47 locale for the displayed times.
Shown while empty. Defaults to "Pick a time".
Trigger size. Defaults to "md".
Error state; set automatically inside a <Field error>.
Stretch the trigger to the container width.
Form field name: submits "HH:mm".
Accessible names (TimePickerLabels). Default to "Choose time", "Times", "Hours", "Minutes" and "AM/PM".
Class for the outer wrapper (className goes to the trigger button).
The ref and native <button> attributes (except value, defaultValue, onChange and children) go to the trigger button.
Styling
Root class cherry-time-picker with data-size (sm, md, lg), data-layout (list, columns) and states data-open, data-invalid, data-disabled, data-full-width. Options use aria-selected and aria-disabled. Parts: cherry-time-picker__trigger, __icon, __value, __placeholder, __popover, __list, __columns, __column, __option, __option-label, __check.
Reads the field tokens for the trigger, --cherry-bg-elevated and --cherry-elevation-lg for the popover, and --cherry-primary-default with --cherry-primary-fg for the selected option.
Accessibility
A listbox of times: Up and Down, Home and End move, Enter selects, Escape closes and returns focus to the trigger. With layout="columns", Left and Right move between the hour, minute and AM/PM columns. Label it with Field.