Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Forms

DateTimePicker

Free36.8 KB gzipped

A 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

tsx
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.

Date
Format: MM/DD/YYYY
Time
Example: 2:30 PM
tsx
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

التاريخ
التنسيق: يي/شش/سسسس
الوقت
مثال: 2:30 م
tsx
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.

tsx
<Field label="Tip-off">
  <DateTimePicker name="tipoff" defaultTime="19:00" step={15} />
</Field>

API reference

DateTimePicker

New in 1.5.0
DateTimePicker props
PropTypeDefault
value

Selected date and time, "YYYY-MM-DDTHH:mm", or null (controlled).

ISODateTime | null—
defaultValue

Initial value when uncontrolled.

ISODateTime | null—
onValueChange

Called 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—
min

Earliest allowed moment, "YYYY-MM-DDTHH:mm". Its time applies on its own date only.

ISODateTime—
max

Latest allowed moment, "YYYY-MM-DDTHH:mm". Its time applies on its own date only.

ISODateTime—
isDateDisabled

Marks individual dates unavailable.

(date: ISODate, dateObject: Date) => boolean—
step

Minutes between the times in the time list.

number30
hourCycle

12-hour (AM/PM) or 24-hour clock. Defaults to the locale's.

1224—
defaultTime

Time 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—
locale

BCP 47 locale for formats and labels. Defaults to the LocaleProvider locale.

string—
weekStartsOn

First day of the week in the calendar. Defaults to the locale's.

0123456—
today

Override "today" ("YYYY-MM-DD") in the calendar, e.g. for tests.

ISODate—
size

Field size. Inherits from a surrounding Field.

"sm""md""lg""md"
name

Name of a hidden input that submits "YYYY-MM-DDTHH:mm" with a form.

string—
clearable

Shows clear buttons in both fields.

booleanfalse
invalid

Danger styling and aria-invalid. Inherits from a surrounding Field.

boolean—
required

Requires both a date and a time. Inherits from a surrounding Field.

boolean—
disabled

Disables both fields. Inherits from a surrounding Field.

boolean—
readOnly

Shows the value without allowing changes. Inherits from a surrounding Field.

boolean—
placement

Where 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"
dateLabel

Visible label of the date field.

string"Date"
timeLabel

Visible label of the time field.

string"Time"
onInvalidDate

Called when the date field rejects typed text.

(error: DateInputError) => void—
onInvalidTime

Called when the time field rejects typed text.

(error: TimeInputError) => void—
fullWidth

Stretches the fields to fill the container.

booleantrue
id

Id for the date input. Inside a Field, the Field's id is used, so its label points there.

string—
aria-label

Accessible name of the pair, when there is no Field label.

string—
aria-describedby

Ids of elements that describe both fields.

string—
className

Class name for the outer root.

string—
style

Style 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)

Running accessibility audit

Checking the examples above…

Lighthouse audit

Light mode

Score 100

37 passed · 0 failed · 28 not applicable · 10 to check by hand

Dark mode

Score 100

37 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

Keyboard
KeyAction
TabMoves from the date field to the time field.
Alt+Arrow DownIn the date field: opens the calendar (see DatePicker).
Arrow DownIn 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

Roles and states
ElementRoleStates and properties
PairgroupNamed by the Field label (or aria-label)
Date fieldtextboxNamed "Tip-off, Date": the group's label plus its own
Time fieldcomboboxNamed "Tip-off, Time"
ErroralertHint, 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.

Manual accessibility checks
CheckWhat to testWCAG 2.2
KeyboardEvery 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)
FocusFocus 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 readersNames, 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)
ColorMeaning 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 reflowAt 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 targetsClick 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)
MotionAnimations respect the reduced-motion setting.2.3.3 (AAA)