DateTime Picker
A time, or a date and a time, typed into segments or picked from a list.
- Category
- Forms
- Access
- Free with an account
- Source
- 508 lines · one file
- States
- 6 drawn
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 Liro's DateTime Picker for this.
Install it: npx shadcn@latest add @liro/datetime-picker
(the @liro registry is set up in components.json, with LIRO_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 @liro registry with your CLI token: see the Namespaced tab.
Usage
"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.
| Type | Notes | ||
|---|---|---|---|
mode | "time" | "datetime" | No | "time" for a time alone, "datetime" for a date and a time. Default "datetime". |
value | Date | null | No | The chosen moment, or null for none. Controlled. |
defaultValue | Date | null | No | The starting value when uncontrolled. |
onValueChange | (date: Date | null) => void | No | Called with a complete Date, or null when cleared. Never with a half-typed time. |
hourCycle | 12 | 24 | No | 12 shows AM/PM; 24 does not. Default from the reader's locale. |
granularity | "hour" | "minute" | "second" | No | The smallest unit shown. Default "minute". |
minuteStep | number | No | How far the arrow keys move the minutes, e.g. 5 or 15. Default 1. |
timezone | string | No | An IANA zone shown as a label, e.g. "Europe/London". Not converted. |
minDate | Date | No | Earliest day that can be picked. |
maxDate | Date | No | Latest day that can be picked. |
placeholder | string | No | Shown on the date button when no date is chosen. |
clearable | boolean | No | Adds an × that clears the value. |
disabled | boolean | No | Read-only and dimmed. |
size | "sm" | "md" | "lg" | No | sm, md or lg, matching Input and Button. Default md. |
className | string | No | – |
id | string | No | – |
Dependencies
npm packages
clsxdate-fnslucide-reacttailwind-mergeLiro foundations, installed alongside it
liro-themecalendarfieldpopoverStates
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