Date Picker10
A date field with a calendar behind a button, for single dates and ranges. In Sticker it's a desk calendar: pages tear off as you go forward and the picked day gets a sticker. Retro slides pages in steps, Comic bursts the day you pick and Arcade rewrites the month row by row.
<DatePicker label="Departure" />Usage
import { DatePicker, parseDate } from "plonk-ui";
export function Departure() {
return (
<DatePicker
label="Departure"
name="departure"
defaultValue={parseDate("2026-11-14")}
/>
);
}Type the date part by part, change a part with the arrow keys, or open the
calendar with the button. The field submits the date as YYYY-MM-DD under its
name.
Date values
Dates aren't JavaScript Dates: they're CalendarDate objects from
@internationalized/date, without a time or a time zone, so November 14 stays
November 14 everywhere. Plonk re-exports what you need most:
import { CalendarDate, getLocalTimeZone, parseDate, today } from "plonk-ui";
parseDate("2026-11-14"); // from an ISO string
new CalendarDate(2026, 11, 14); // year, month, day
today(getLocalTimeZone()); // today in the user's time zone
date.add({ days: 7 }); // math returns a new date
date.toString(); // "2026-11-14"
date.toDate(getLocalTimeZone()); // back to a JavaScript DateThe format, the month names and the first day of the week follow the
provider's locale; see Localization.
Limits
minValue and maxValue set the earliest and latest dates.
isDateUnavailable crosses out single days, like booked nights. Picking one
marks the field invalid.
import { DatePicker, parseDate, type DateValue } from "plonk-ui";
const BOOKED = ["2026-11-20", "2026-11-21", "2026-11-27"].map((d) =>
parseDate(d),
);
export default function Limits() {
return (
<DatePicker
className="w-full max-w-xs"
label="Check-in"
description="Between Nov 3 and Dec 20. Some nights are booked."
defaultValue={parseDate("2026-11-12")}
minValue={parseDate("2026-11-03")}
maxValue={parseDate("2026-12-20")}
isDateUnavailable={(date: DateValue) =>
BOOKED.some((booked) => booked.compare(date) === 0)
}
/>
);
}Ranges and presets
DateRangePicker picks a start and an end, and its value is { start, end }.
presets adds ready-made ranges next to the calendar. Give a preset's range
as a function, and it's computed when pressed, so "today" is always today.
import { useState } from "react";
import {
DateRangePicker,
getLocalTimeZone,
parseDate,
today,
type DateRange,
} from "plonk-ui";
// Functions run when the preset is pressed, so "today" is always fresh.
const PRESETS = [
{
label: "Last 7 days",
range: () => {
const end = today(getLocalTimeZone());
return { start: end.subtract({ days: 6 }), end };
},
},
{
label: "This month",
range: () => {
const now = today(getLocalTimeZone());
return { start: now.set({ day: 1 }), end: now };
},
},
];
export default function Range() {
const [range, setRange] = useState<DateRange | null>({
start: parseDate("2026-11-02"),
end: parseDate("2026-11-08"),
});
return (
<div className="flex w-full max-w-sm flex-col gap-3">
<DateRangePicker
label="Report period"
presets={PRESETS}
value={range}
onChange={setRange}
/>
<span className="font-bold">
{range ? `${range.start} → ${range.end}` : "No period"}
</span>
</div>
);
}In a form, name both ends with startName and endName.
Calendar
Calendar and RangeCalendar are the calendars on their own, to put right on
the page, like a delivery date picker.
import { useState, useSyncExternalStore } from "react";
import { Calendar, parseDate } from "plonk-ui";
// A calendar on the page reads "today" while rendering, so draw it in the
// browser only (see "Server rendering" below).
const noop = () => () => {};
const useIsClient = () =>
useSyncExternalStore(
noop,
() => true,
() => false,
);
export default function InlineCalendar() {
const isClient = useIsClient();
const [date, setDate] = useState(parseDate("2026-11-14"));
if (!isClient) return <div className="h-[23rem] w-full max-w-80" />;
return (
<div className="flex flex-col items-center gap-3">
<Calendar aria-label="Delivery date" value={date} onChange={setDate} />
<span className="font-bold">Delivery: {date.toString()}</span>
</div>
);
}Server rendering
A calendar on the page decides which month to show, and which day is today,
while it renders. With Next.js Cache Components, reading "now" during a
prerender stops the build ("used Date.now()"). So:
DatePickerandDateRangePickerare safe: Plonk renders their fields without reading the clock on the server.CalendarandRangeCalendaron the page read it: render them in the browser only, as in the example above, or wrap them in<Suspense>.- Don't call
today()while rendering either. Call it in an event handler, or in a preset'srangefunction.
Personalities
- Sticker: going forward, the page tears off at a ragged edge and falls; going back, it sticks on from the top. The picked day gets a sticker, a range is drawn with a highlighter and today has a pen circle.
- Retro: pages slide in steps, the picked day is inverted and a range fills with a dither pattern.
- Comic: a halftone panel with the month in a caption box. The picked day is a burst, a range a strip of blue halftone, and today is marked in yellow.
- Arcade: the month is wiped and retyped row by row. The picked day is a pink neon box with a blinking cursor, a range a cyan neon strip, and today has a star.
With reduced motion, pages change without flying and selections appear without animating.
Accessibility
- Each part of the field (day, month, year) is a spin button: type a number, or
use
↑and↓.←and→move between parts. - In the calendar, arrow keys move by day and week,
Page UpandPage Downby month, andEnterpicks. - Screen readers hear full dates ("Saturday, November 14, 2026"), and unavailable days are announced as such.
- The calendar opens in a dialog that keeps focus inside and returns it to the button when it closes.
API
DatePicker
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Extra classes for the outer wrapper. |
label | ReactNode | — | Visible label, linked to the field. |
description | ReactNode | — | Help text under the field. |
error | ReactNode | — | Error message. Marks the field invalid and shakes it once. Pass true to mark it without a message. |
value | DateValue | null | — | Controlled date, a CalendarDate (parseDate("2026-11-14")) or null. |
defaultValue | DateValue | null | — | Date on first render, when uncontrolled. |
onChange | (value: DateValue | null) => void | — | Called with the new date, or null when cleared. |
minValue | DateValue | null | — | Earliest date that can be picked. |
maxValue | DateValue | null | — | Latest date that can be picked. |
isDateUnavailable | (date: DateValue) => boolean | — | Return true for dates that can't be picked, like booked nights. They stay visible but crossed out. |
placeholderValue | DateValue | null | — | Date the empty field and the calendar start from. Defaults to today. |
name | string | — | Field name: the date is submitted as YYYY-MM-DD. |
isRequired | boolean | — | Marks the field required, with an asterisk in the label. |
isDisabled | boolean | — | Disables the field. |
isReadOnly | boolean | — | Shows the date but doesn't let it change. |
DateRangePicker
| Prop | Type | Default | Description |
|---|---|---|---|
presets | CalendarPreset[] | — | Ready-made ranges next to the calendar: { label, range }. Pass range as a function to compute it when pressed. |
className | string | — | Extra classes for the outer wrapper. |
label | ReactNode | — | Visible label, linked to the field. |
description | ReactNode | — | Help text under the field. |
error | ReactNode | — | Error message. Marks the field invalid and shakes it once. Pass true to mark it without a message. |
value | DateRange | null | — | Controlled range, { start, end }, or null. |
defaultValue | DateRange | null | — | Range on first render, when uncontrolled. |
onChange | (value: DateRange | null) => void | — | Called with the new range once both ends are picked. |
minValue | DateValue | null | — | Earliest date that can be picked. |
maxValue | DateValue | null | — | Latest date that can be picked. |
isDateUnavailable | (date: DateValue) => boolean | — | Return true for dates that can't be picked, like booked nights. They stay visible but crossed out. |
startName | string | — | Field name for the start date in form data. |
endName | string | — | Field name for the end date in form data. |
isRequired | boolean | — | Marks the field required, with an asterisk in the label. |
isDisabled | boolean | — | Disables the field. |
Calendar
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Extra classes for the calendar. |
value | DateValue | null | — | Controlled date. |
defaultValue | DateValue | null | — | Date on first render, when uncontrolled. |
onChange | (value: DateValue) => void | — | Called with the picked date. |
minValue | DateValue | null | — | Earliest date that can be picked. |
maxValue | DateValue | null | — | Latest date that can be picked. |
isDateUnavailable | (date: DateValue) => boolean | — | Return true for dates that can't be picked, like booked nights. They stay visible but crossed out. |
isDisabled | boolean | false | Disables the whole calendar. |
aria-label | string | — | Name of the calendar, for screen readers. |
RangeCalendar
| Prop | Type | Default | Description |
|---|---|---|---|
presets | CalendarPreset[] | — | Ready-made ranges next to the calendar. |
className | string | — | Extra classes for the calendar. |
value | DateRange | null | — | Controlled range, { start, end }. |
defaultValue | DateRange | null | — | Range on first render, when uncontrolled. |
onChange | (value: DateRange) => void | — | Called once both ends are picked. |
minValue | DateValue | null | — | Earliest date that can be picked. |
maxValue | DateValue | null | — | Latest date that can be picked. |
isDateUnavailable | (date: DateValue, anchorDate: CalendarDate | null) => boolean | — | Return true for dates that can't be picked, like booked nights. They stay visible but crossed out. |
isDisabled | boolean | false | Disables the whole calendar. |
aria-label | string | — | Name of the calendar, for screen readers. |