Forms
DateTimePicker
Free36.8 KB gzippedA date and a time together: a DatePicker and a TimePicker side by side, with one value, "YYYY-MM-DDTHH:mm" (the format of a native datetime-local input, with no time zone). Each half keeps its full behavior: typed dates in the locale's format or the calendar popup, typed times in any common form or the list of times.
Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · Keys: Tab, Alt+Arrow Down, Arrow Down · Full report
Import
import { DateTimePicker } from "@vjdesigns/vjdesigns-ui";
Importing only DateTimePicker adds about 36.8 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.
Examples
Basic
A date and a time with one value, "YYYY-MM-DDTHH:mm" (like a native datetime-local input, with no time zone). The pair is a group named by the Field label, and each half adds its own: "Tip-off, Date", "Tip-off, Time". defaultTime fills the time when a date is picked first.
import { DateTimePicker, Field } from "@vjdesigns/vjdesigns-ui";
export function Basic() {
return (
<Field label="Tip-off" style={{ width: "100%", maxWidth: "28rem" }}>
<DateTimePicker name="tipoff" defaultTime="19:00" step={15} />
</Field>
);
}
Right to left
The first example again, inside a right-to-left LocaleProvider (Arabic). Layout, spacing and arrow icons mirror, and the components' built-in text is translated. The example's own text stays in English.
Basic
import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";
// Basic is the "Basic" example above.
<LocaleProvider locale="ar" messages={ar}>
<Basic />
</LocaleProvider>
Usage notes
min and max limit the calendar by their dates, and the time list by their times on those boundary dates. defaultTime fills the time when a date is picked first.
Accessibility: the pair is a role="group" named by the Field label (or aria-label); each field is named by that label plus its own visible label ("Tip-off, Date", "Tip-off, Time"). Field hint, error, required, disabled, and invalid state reach both.
<Field label="Tip-off">
<DateTimePicker name="tipoff" defaultTime="19:00" step={15} />
</Field>
API reference
DateTimePicker
New in 1.5.0| Prop | Type | Default |
|---|---|---|
valueSelected date and time, "YYYY-MM-DDTHH:mm", or null (controlled). | ISODateTime | null | — |
defaultValueInitial value when uncontrolled. | ISODateTime | null | — |
onValueChangeCalled with "YYYY-MM-DDTHH:mm" once both a date and a time are set, and with null when either is cleared or invalid. | (value: ISODateTime | null) => void | — |
minEarliest allowed moment, "YYYY-MM-DDTHH:mm". Its time applies on its own date only. | ISODateTime | — |
maxLatest allowed moment, "YYYY-MM-DDTHH:mm". Its time applies on its own date only. | ISODateTime | — |
isDateDisabledMarks individual dates unavailable. | (date: ISODate, dateObject: Date) => boolean | — |
stepMinutes between the times in the time list. | number | 30 |
hourCycle12-hour (AM/PM) or 24-hour clock. Defaults to the locale's. | 1224 | — |
defaultTimeTime filled in when a date is picked while the time is empty (e.g. "09:00"), so one pick gives a complete value. Without it, the value stays null until a time is set. | ISOTime | — |
localeBCP 47 locale for formats and labels. Defaults to the | string | — |
weekStartsOnFirst day of the week in the calendar. Defaults to the locale's. | 0123456 | — |
todayOverride "today" ("YYYY-MM-DD") in the calendar, e.g. for tests. | ISODate | — |
sizeField size. Inherits from a surrounding | "sm""md""lg" | "md" |
nameName of a hidden input that submits "YYYY-MM-DDTHH:mm" with a form. | string | — |
clearableShows clear buttons in both fields. | boolean | false |
invalidDanger styling and | boolean | — |
requiredRequires both a date and a time. Inherits from a surrounding | boolean | — |
disabledDisables both fields. Inherits from a surrounding | boolean | — |
readOnlyShows the value without allowing changes. Inherits from a surrounding | boolean | — |
placementWhere the calendar and the time list open. | "top""top-start""top-end""bottom""bottom-start""bottom-end""left""left-start""left-end""right""right-start""right-end" | "bottom-start" |
dateLabelVisible label of the date field. | string | "Date" |
timeLabelVisible label of the time field. | string | "Time" |
onInvalidDateCalled when the date field rejects typed text. | (error: DateInputError) => void | — |
onInvalidTimeCalled when the time field rejects typed text. | (error: TimeInputError) => void | — |
fullWidthStretches the fields to fill the container. | boolean | true |
idId for the date input. Inside a | string | — |
aria-labelAccessible name of the pair, when there is no | string | — |
aria-describedbyIds of elements that describe both fields. | string | — |
classNameClass name for the outer root. | string | — |
styleStyle for the outer root. | CSSProperties | — |
See what changed in each version in the Changelog.
Accessibility report
DateTimePicker targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.
axe-core audit (live)
Checking the examples above…
Lighthouse audit
Light mode
Score 10037 passed · 0 failed · 28 not applicable · 10 to check by hand
Dark mode
Score 10037 passed · 0 failed · 28 not applicable · 10 to check by hand
Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.
Built-in behavior
Keyboard
| Key | Action |
|---|---|
| Tab | Moves from the date field to the time field. |
| Alt+Arrow Down | In the date field: opens the calendar (see DatePicker). |
| Arrow Down | In the time field: opens the list of times (see TimePicker). |
Each half keeps its full keyboard model: DatePicker's calendar grid and TimePicker's list.
Roles and states
| Element | Role | States and properties |
|---|---|---|
| Pair | group | Named by the Field label (or aria-label) |
| Date field | textbox | Named "Tip-off, Date": the group's label plus its own |
| Time field | combobox | Named "Tip-off, Time" |
| Error | alert | Hint, error, required and invalid state reach both fields |
Manual checks
Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.
| Check | What to test | WCAG 2.2 |
|---|---|---|
| Keyboard | Every action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck. | 2.1.1 (A), 2.1.2 (A) |
| Focus | Focus moves in a logical order, is always visible, and isn't hidden behind sticky headers. | 2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA) |
| Screen readers | Names, roles and states are announced correctly, and status changes are announced without moving focus. | 1.3.1 (A), 4.1.2 (A), 4.1.3 (AA) |
| Color | Meaning never depends on color alone; your own colors meet contrast in both modes. | 1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA) |
| Zoom and reflow | At 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed. | 1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA) |
| Pointer targets | Click and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap. | 2.5.8 (AA), 2.5.5 (AAA) |
| Motion | Animations respect the reduced-motion setting. | 2.3.3 (AAA) |