DateTimePicker
"use client";
import { DateTimePicker, Field } from "@cherry-design-system/react";
export function PublishAt() {
return (
<Field label="Publish at">
<DateTimePicker name="publishAt" locale="en-GB" hourCycle={24} fullWidth />
</Field>
);
}Picks a day and a time in one popover: a Calendar beside a column of time slots, then Cancel or Apply. It reuses the DatePicker trigger. Use DatePicker or TimePicker when you only need one of the two.
onChange runs only on Apply. With name, a hidden input submits "YYYY-MM-DDTHH:mm" in local time.
If you import per-component CSS from @cherry-design-system/react/css/* instead of styles.css, DateTimePicker needs date-picker.css, calendar.css, time-picker.css and button.css besides its own stylesheet.
Examples
Controlled
"use client";
import { useState } from "react";
import { DateTimePicker, Field } from "@cherry-design-system/react";
export function Meeting() {
const [when, setWhen] = useState<Date | null>(null);
return (
<Field label="Meeting" hint={when ? when.toISOString() : "Not scheduled"}>
<DateTimePicker value={when} onChange={setWhen} step={15} hourCycle={12} />
</Field>
);
}Limits and disabled days
"use client";
import { DateTimePicker, Field } from "@cherry-design-system/react";
const now = new Date();
export function Delivery() {
return (
<Field label="Delivery window" required>
<DateTimePicker
min={now}
isDateDisabled={(d) => d.getDay() === 0}
dateFormatOptions={{ weekday: "short", day: "numeric", month: "short" }}
placeholder="Choose a delivery slot"
/>
</Field>
);
}Translated labels
"use client";
import { DateTimePicker, Field } from "@cherry-design-system/react";
export function Cita() {
return (
<Field label="Cita">
<DateTimePicker
locale="es-ES"
weekStartsOn={1}
labels={{ dialog: "Elegir fecha y hora", time: "Hora", cancel: "Cancelar", apply: "Aplicar" }}
calendarLabels={{ previousMonth: "Mes anterior", nextMonth: "Mes siguiente" }}
/>
</Field>
);
}Properties
Controlled date and time.
Initial value when uncontrolled. Defaults to null.
Called on Apply with the picked day at the picked time.
Earliest selectable day.
Latest selectable day.
Extra rule for unavailable days.
Minutes between time slots. Defaults to 30.
12 or 24-hour clock for the slots.
BCP 47 locale for the calendar, the slots and the trigger text.
First day of the week, 0 = Sunday.
How the trigger shows the day. Defaults to { dateStyle: "medium" }.
Shown while empty. Defaults to "Pick a date and 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 "YYYY-MM-DDTHH:mm" (local time).
Accessible names and button text (DateTimePickerLabels). Default to "Choose date and time", "Time", "Cancel" and "Apply".
Labels passed to the Calendar's month buttons.
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-date-time-picker with states data-open, data-invalid and data-disabled. Parts: cherry-date-time-picker__popover, __body, __time, __time-label, __footer. The trigger uses the DatePicker classes (cherry-date-picker__trigger and so on), the grid uses the Calendar classes and the slots use the TimePicker option classes.
Reads --cherry-border-default for the divider, --cherry-fg-muted for the time label and --cherry-primary-default with --cherry-primary-fg for the selected slot.
Accessibility
A dialog with the Calendar grid and a time listbox; Cancel and Apply are buttons. Escape closes the dialog and returns focus to the trigger. Label it with Field.