Data
Date Picker
Calendar in a popover behind a plain-spoken button. Single date or range, controlled or not.
Sowing day
Trip dates
Show codeHide code
"use client";
import { useState } from "react";
import type { DateRange } from "react-day-picker";
import { DatePicker, DateRangePicker } from "@/registry/lilt/ui/date-picker";
export default function DatePickerDemo() {
const [sowDate, setSowDate] = useState<Date | undefined>();
const [tripDates, setTripDates] = useState<DateRange | undefined>();
return (
<div className="flex w-full max-w-xs flex-col gap-6">
<div className="flex flex-col gap-1.5">
<span className="font-display text-xs font-bold uppercase tracking-[0.15em] text-[var(--lilt-text-muted)]">
Sowing day
</span>
<DatePicker
onValueChange={setSowDate}
placeholder="When do seeds go in?"
value={sowDate}
/>
</div>
<div className="flex flex-col gap-1.5">
<span className="font-display text-xs font-bold uppercase tracking-[0.15em] text-[var(--lilt-text-muted)]">
Trip dates
</span>
<DateRangePicker
onValueChange={setTripDates}
placeholder="While the garden waits"
value={tripDates}
/>
</div>
</div>
);
}Installation
npx shadcn@latest add @lilt/date-pickerAccessibility
- The trigger is a real button whose accessible name includes the chosen date; Escape closes the popover and returns focus to it.
- Pair it with a visible Label (or aria-label) so the empty 'Pick a date' state still announces the field's purpose.