OfferLifetime Pro for $99

DateTime Picker

A time field in hh : mm segments with AM/PM, and a date from the Layro Calendar beside it. Type 9 and it moves to the minutes, arrows step by your minute interval, the clock opens a list of times for a mouse or a phone, and a time zone shows as a label.

FormsFree508 lines · one file

The decision inside it

Nothing is sent until the time is whole

A half-typed time stays inside the field, so your form never receives midnight because someone typed one digit. The value is set with setHours on a copy of the day, so a daylight-saving day keeps the time the reader typed.

When to use it

Use DateTime Picker for a time, or a date and a time together: typed segments with arrow-key stepping, 12 or 24 hours, a minute step, and a time-zone label. For a date alone, use Date Picker.

Installation

How you get it

Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.

Use Layro's DateTime Picker for this.
Install it: npx shadcn@latest add @layro/datetime-picker
(the @layro registry is set up in components.json, with LAYRO_KEY in .env.local)
Import it from @/components/ui/datetime-picker.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.

For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Free components install through the @layro registry with your CLI token: see the Namespaced tab.

Usage

components/schedule-call.tsx
"use client";

import * as React from "react";
import { DateTimePicker } from "@/components/ui/datetime-picker";
import { Field } from "@/components/ui/field";

export function ScheduleCall() {
  const [at, setAt] = React.useState<Date | null>(null);
  return (
    <Field label="Call time">
      <DateTimePicker value={at} onValueChange={setAt} hourCycle={12} minuteStep={15} timezone="Europe/London" clearable />
    </Field>
  );
}

API reference

“Copy prompt” above puts a full brief on your clipboard — install command, dependencies, props, and the mistakes an assistant usually makes with this component.

Props

Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.

PropTypeNotes
mode"time" | "datetime""time" for a time alone, "datetime" for a date and a time. Default "datetime".
valueDate | nullThe chosen moment, or null for none. Controlled.
defaultValueDate | nullThe starting value when uncontrolled.
onValueChange(date: Date | null) => voidCalled with a complete Date, or null when cleared. Never with a half-typed time.
hourCycle12 | 2412 shows AM/PM; 24 does not. Default from the reader's locale.
granularity"hour" | "minute" | "second"The smallest unit shown. Default "minute".
minuteStepnumberHow far the arrow keys move the minutes, e.g. 5 or 15. Default 1.
timezonestringAn IANA zone shown as a label, e.g. "Europe/London". Not converted.
minDateDateEarliest day that can be picked.
maxDateDateLatest day that can be picked.
placeholderstringShown on the date button when no date is chosen.
clearablebooleanAdds an × that clears the value.
disabledbooleanRead-only and dimmed.
size"sm" | "md" | "lg"sm, md or lg, matching Input and Button. Default md.
classNamestring—
idstring—

Dependencies

npm packages

clsxdate-fnslucide-reacttailwind-merge

Layro foundations, installed alongside it

layro-themecalendarfieldpopover

States

All of them are drawn by the component. None is left for you to design.

  • Empty
  • Date and time
  • Time only
  • 12 hour
  • 24 hour
  • Disabled

Accessibility

  • Keyboard reachable throughout, in visual order
  • Focus trapped in overlays, Escape closes them
  • Focus returns to whatever opened it
  • Live regions announce what changed, not that something did
  • Honours prefers-reduced-motion

Responsive behavior

  • Sizes to its container, not the viewport
  • Usable from 320px up
  • Pointer-based interaction, so trackpad and touch both work
  • No hover-only affordances

Lifetime access

Every component, and everything we ship next.

  • All 232 components, source included
  • Every template, and everything released after you buy
  • shadcn CLI or download — React 18/19, Tailwind v4
  • One payment. No subscription.