Examples

Basic

The hidden input submits ISO 8601 (2026-11-10).

Preview

Type it, or use the calendar (Alt + ↓).

Example.tsx
import { DatePicker, parseDate } from '@reactloom/dates';

export default function Example() {
  return (
    <div style={{ width: '100%', maxWidth: 280 }}>
      <DatePicker label="Due date" name="due" defaultValue={parseDate('2026-11-10')} description="Type it, or use the calendar (Alt + ↓)." />
    </div>
  );
}

Range

Two fields and a two-month range calendar.

Preview
Example.tsx
import { DateRangePicker, parseDate } from '@reactloom/dates';

export default function Example() {
  // Fixed dates keep the prerendered page and the live example identical.
  return (
    <DateRangePicker
      label="Stay"
      startName="checkIn"
      endName="checkOut"
      minValue={parseDate('2026-01-01')}
      defaultValue={{ start: parseDate('2026-11-12'), end: parseDate('2026-11-16') }}
    />
  );
}

Constraints

min/max and unavailable dates are enforced in the field and the calendar.

Preview
Example.tsx
import { DatePicker, getLocalTimeZone, isWeekend, today, type DateValue } from '@reactloom/dates';
import { useLocale } from '@reactloom/ui';
import { useState } from 'react';

export default function Example() {
  const { locale } = useLocale();
  const now = today(getLocalTimeZone());
  const [value, setValue] = useState<DateValue | null>(null);
  const weekend = value ? isWeekend(value, locale) : false;
  return (
    <div style={{ width: '100%', maxWidth: 280 }}>
      <DatePicker
        label="Delivery"
        value={value}
        onValueChange={setValue}
        minValue={now.add({ days: 1 })}
        maxValue={now.add({ months: 2 })}
        isDateUnavailable={(date) => isWeekend(date, locale)}
        error={weekend ? 'We do not deliver at weekends.' : undefined}
        required
      />
    </div>
  );
}

API reference

DatePicker props

DatePicker props
PropTypeDefault
label
Visible label, associated with the control.
ReactNode—
description
Help text linked with aria-describedby.
ReactNode—
error
Error message; marks the control invalid and is described.
ReactNode—
invalid
Invalid without a message.
booleanfalse
hideLabel
Keep the label for screen readers, hide it visually.
booleanfalse
value / defaultValue
CalendarDate, CalendarDateTime or ZonedDateTime.
DateValue | null—
onValueChange
(value) => void—
minValue · maxValue
DateValue—
isDateUnavailable
(date) => boolean—
granularity
Adds time segments.
'day' | 'hour' | 'minute' | 'second''day'
hourCycle
Defaults to the locale.
12 | 24—
name
Submits ISO 8601.
string—
visibleMonths
1 | 2 | 31 (range: 2)
calendarLabel
Translate this.
string'Calendar'
keepOpenOnSelect
booleanfalse
required · disabled · readOnly · size
—

DateRangePicker (differences)

DateRangePicker (differences)
PropTypeDefault
value / defaultValue
{ start, end } | null—
startName · endName
Form field names.
string—
allowsNonContiguousRanges
Allow ranges spanning unavailable dates.
booleanfalse

Customization

Extracted from the component’s source on every build, so it matches the code. How the layers fit together is explained in Customization.

DatePicker

CSS variables

VariableDefault
--pl-input-radiusvar(--pl-radius-md

State attributes

Target these in your CSS to style states without depending on class names.

AttributeValues
[data-picker]present when on

Theme tokens it reads

--pl-color-bg-subtle --pl-color-border-default --pl-color-border-focus --pl-color-fg-default --pl-color-fg-disabled --pl-color-fg-muted --pl-focus-ring-color --pl-focus-ring-width --pl-radius-md --pl-radius-sm --pl-shadow-xs

DateRangePicker

CSS variables

VariableDefault
--pl-input-radiusvar(--pl-radius-md

State attributes

Target these in your CSS to style states without depending on class names.

AttributeValues
[data-picker]present when on

Theme tokens it reads

--pl-color-bg-subtle --pl-color-border-default --pl-color-border-focus --pl-color-fg-default --pl-color-fg-disabled --pl-color-fg-muted --pl-focus-ring-color --pl-focus-ring-width --pl-radius-md --pl-radius-sm --pl-shadow-xs

Accessibility

  • Each part of the date is a spin button named by its unit; screen readers announce the full date.
  • The calendar opens in a labelled dialog; focus moves to the selected date and returns to the button on close.
  • Arrow keys move by day/week, Page Up/Down by month (Shift: year), Home/End to the week bounds.
  • Unavailable dates stay focusable and are announced as unavailable.
Keyboard interactions
KeyAction
← / →Previous / next segment (field) · day (calendar)
↑ / ↓Change the segment (field) · week (calendar)
Alt + ↓Open the calendar
Page Up / Page DownPrevious / next month
EnterSelect the focused date
EscapeClose the calendar

Usage guidelines

Do

  • Let people type: it is faster than any calendar for known dates such as birthdays.
  • Use placeholderValue to start the calendar near likely dates.

Don’t

  • Don’t convert to JavaScript Date for storage — keep the ISO string or the date object.