Components / Date and time

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 · PlaygroundLive
Departure
JSX
<DatePicker label="Departure" />

Usage

TSX
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:

TS
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 Date

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

Date Picker · LimitsLive
Check-in
Between Nov 3 and Dec 20. Some nights are booked.
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.

Date Picker · RangeLive
Report period
2026-11-02 → 2026-11-08
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.

Date Picker · CalendarLive
TSX
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:

  • DatePicker and DateRangePicker are safe: Plonk renders their fields without reading the clock on the server.
  • Calendar and RangeCalendar on 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's range function.

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 Up and Page Down by month, and Enter picks.
  • 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

PropTypeDefaultDescription
classNamestring—Extra classes for the outer wrapper.
labelReactNode—Visible label, linked to the field.
descriptionReactNode—Help text under the field.
errorReactNode—Error message. Marks the field invalid and shakes it once. Pass true to mark it without a message.
valueDateValue | null—Controlled date, a CalendarDate (parseDate("2026-11-14")) or null.
defaultValueDateValue | null—Date on first render, when uncontrolled.
onChange(value: DateValue | null) => void—Called with the new date, or null when cleared.
minValueDateValue | null—Earliest date that can be picked.
maxValueDateValue | 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.
placeholderValueDateValue | null—Date the empty field and the calendar start from. Defaults to today.
namestring—Field name: the date is submitted as YYYY-MM-DD.
isRequiredboolean—Marks the field required, with an asterisk in the label.
isDisabledboolean—Disables the field.
isReadOnlyboolean—Shows the date but doesn't let it change.

DateRangePicker

PropTypeDefaultDescription
presetsCalendarPreset[]—Ready-made ranges next to the calendar: { label, range }. Pass range as a function to compute it when pressed.
classNamestring—Extra classes for the outer wrapper.
labelReactNode—Visible label, linked to the field.
descriptionReactNode—Help text under the field.
errorReactNode—Error message. Marks the field invalid and shakes it once. Pass true to mark it without a message.
valueDateRange | null—Controlled range, { start, end }, or null.
defaultValueDateRange | null—Range on first render, when uncontrolled.
onChange(value: DateRange | null) => void—Called with the new range once both ends are picked.
minValueDateValue | null—Earliest date that can be picked.
maxValueDateValue | 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.
startNamestring—Field name for the start date in form data.
endNamestring—Field name for the end date in form data.
isRequiredboolean—Marks the field required, with an asterisk in the label.
isDisabledboolean—Disables the field.

Calendar

PropTypeDefaultDescription
classNamestring—Extra classes for the calendar.
valueDateValue | null—Controlled date.
defaultValueDateValue | null—Date on first render, when uncontrolled.
onChange(value: DateValue) => void—Called with the picked date.
minValueDateValue | null—Earliest date that can be picked.
maxValueDateValue | 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.
isDisabledbooleanfalseDisables the whole calendar.
aria-labelstring—Name of the calendar, for screen readers.

RangeCalendar

PropTypeDefaultDescription
presetsCalendarPreset[]—Ready-made ranges next to the calendar.
classNamestring—Extra classes for the calendar.
valueDateRange | null—Controlled range, { start, end }.
defaultValueDateRange | null—Range on first render, when uncontrolled.
onChange(value: DateRange) => void—Called once both ends are picked.
minValueDateValue | null—Earliest date that can be picked.
maxValueDateValue | 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.
isDisabledbooleanfalseDisables the whole calendar.
aria-labelstring—Name of the calendar, for screen readers.