Dates
DatePicker & DateRangePicker
Type a date into locale-ordered segments, or pick it from a calendar. Values are @internationalized/date objects, so there are no time-zone surprises from JavaScript Date.
import '@reactloom/dates/styles.css';
import { DatePicker, DateRangePicker, parseDate } from '@reactloom/dates';Examples
Basic
The hidden input submits ISO 8601 (2026-11-10).
Type it, or use the calendar (Alt + ↓).
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.
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.
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
| Prop | Type | Default |
|---|---|---|
labelVisible label, associated with the control. | ReactNode | — |
descriptionHelp text linked with aria-describedby. | ReactNode | — |
errorError message; marks the control invalid and is described. | ReactNode | — |
invalidInvalid without a message. | boolean | false |
hideLabelKeep the label for screen readers, hide it visually. | boolean | false |
value / defaultValueCalendarDate, CalendarDateTime or ZonedDateTime. | DateValue | null | — |
onValueChange | (value) => void | — |
minValue · maxValue | DateValue | — |
isDateUnavailable | (date) => boolean | — |
granularityAdds time segments. | 'day' | 'hour' | 'minute' | 'second' | 'day' |
hourCycleDefaults to the locale. | 12 | 24 | — |
nameSubmits ISO 8601. | string | — |
visibleMonths | 1 | 2 | 3 | 1 (range: 2) |
calendarLabelTranslate this. | string | 'Calendar' |
keepOpenOnSelect | boolean | false |
required · disabled · readOnly · size | | — |
DateRangePicker (differences)
| Prop | Type | Default |
|---|---|---|
value / defaultValue | { start, end } | null | — |
startName · endNameForm field names. | string | — |
allowsNonContiguousRangesAllow ranges spanning unavailable dates. | boolean | false |
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
| Variable | Default |
|---|---|
--pl-input-radius | var(--pl-radius-md |
State attributes
Target these in your CSS to style states without depending on class names.
| Attribute | Values |
|---|---|
[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
| Variable | Default |
|---|---|
--pl-input-radius | var(--pl-radius-md |
State attributes
Target these in your CSS to style states without depending on class names.
| Attribute | Values |
|---|---|
[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.
| Key | Action |
|---|---|
| ← / → | Previous / next segment (field) · day (calendar) |
| ↑ / ↓ | Change the segment (field) · week (calendar) |
| Alt + ↓ | Open the calendar |
| Page Up / Page Down | Previous / next month |
| Enter | Select the focused date |
| Escape | Close 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.