Skip to content
Slotted

Date Range Picker

Two segmented date fields in one frame with a two-month calendar behind a trigger, for a start and an end date that the reader can type or choose.

mm
dd
yyyy
mm
dd
yyyy

Type both dates or choose them from the calendar.

Installation

The packages are a 0.x beta on npm, and their public API changes between beta releases without deprecation. One line installs the binding and the default theme.

bash
pnpm add @slotted/react @slotted/theme @slotted/themes
tsx
import { DateRangePicker, DateRangePickerDefaultsProvider } from '@slotted/react';

Typing or choosing

Each end is its own date field: type the month, day and year of the start, and Tab moves on to the end. Or press the calendar button and choose two days. The first press in the calendar starts the range and the second closes it; the panel holds both as a draft until Apply. Between the two ends, the head of the panel shows the length the next press would make, and its two steps move the end one day. The value reports its reason: keyboard or blur for a typed end, select for a range applied from the panel, and clear for the clear button. A two-digit year resolves through yearPivot, as in the date field.

mm
dd
yyyy
mm
dd
yyyy

Type both dates, or choose two days in the calendar.

Two months, or one

The panel shows two months side by side, because a range often crosses a month boundary. months sets another count. One month suits ranges that stay inside a month, such as a promotion. Under 760 pixels the panel shows one month.

10
05
2026
10
18
2026

Promotions run inside one month.

Sizes

size sets the frame, both fields and the calendar button to one step of the control scale: sm for toolbars and dense filter panels, md for most forms, lg for sparse forms. Inside a field, an unset size follows the field.

09
01
2026
09
30
2026
10
01
2026
10
31
2026
11
01
2026
10
31
2027

Variants

outline is the default frame. subtle fills the control, for a form on a tinted surface. plain draws no frame at rest and still shows hover and focus. The two fields inside draw no frame of their own: the date range picker draws one frame for both and answers hover, focus and invalid once.

07
01
2026
09
30
2026
07
01
2026
09
30
2026
07
01
2026
09
30
2026

States

Set invalid, readOnly, disabled and required on the field, which passes them to the date range picker; each can also be set on the date range picker itself. An end before its start is invalid without your help: the date range picker marks the end field and the frame, and it does not swap the ends. Read-only keeps both dates legible and focusable. Read-only and disabled both disable the calendar button, so the calendar cannot open.

10
12
2026
10
05
2026

Error:The end date is before the start date.

07
01
2026
09
30
2026

Set by finance when the quarter opens.

11
23
2026
12
31
2026

Unlocks once the pricing review is approved.

Earliest and latest dates

min and max bound both fields and the calendar. The calendar disables the days outside the bounds, and a date typed outside them marks the date range picker invalid and stays in the field. Once both ends are set, each field is also bounded by the other: the start cannot step past the end, and the end cannot step before the start.

mm
dd
yyyy
mm
dd
yyyy

Carriers accept bookings from October 1 to December 31, 2026.

Days or nights

count decides what the length counts. days counts both ends, for a leave request or a rental. nights counts the nights between them, for a hotel stay. The same two dates give 5 days or 4 nights, and the same day at both ends is 1 day or 0 nights. The head of the panel and the calendar button’s accessible name both say the length in that unit.

10
12
2026
10
16
2026

Counted in nights: October 12 to 16 is 4 nights.

10
12
2026
10
16
2026

Counted in days: October 12 to 16 is 5 days.

Shortest and longest range

minLength and maxLength limit the length, counted in the unit count names. Once a start is chosen, the calendar disables the days that would make the range too short or too long, and the footer names the rule, such as “2 to 14 days”. A typed range outside the limits marks the date range picker invalid; the footer says by how much, the days past the limit are marked, and Apply is disabled.

mm
dd
yyyy
mm
dd
yyyy

Rentals run from 2 to 14 days.

Unavailable dates

isDateUnavailable receives each date and returns true for a date the reader cannot choose. The calendar disables those days. A range must not run across an unavailable day: once a start is chosen, the calendar also disables every day beyond the first unavailable day on either side. A typed range that contains an unavailable day marks the date range picker invalid. Describe the rule in the field’s description, so the reader knows why a day is refused.

mm
dd
yyyy
mm
dd
yyyy

Booked October 14 to 16. A booking cannot run across those days.

Ranges across unavailable dates

contiguous={false} lets a range run across unavailable days and checks only its two ends. Use it when the rule is about the days a range starts and ends on, such as a vacation that has to start and end on a working day and may include a weekend.

mm
dd
yyyy
mm
dd
yyyy

Start and end on a working day. Weekends and holidays inside the vacation are fine.

Shortcuts

presets adds a column of shortcuts beside the calendar. Each one is a label and the range it writes, or a function that returns the range when the panel draws it, for a relative shortcut such as the last 7 days. The panel writes the two dates under the label. Pressing one puts its range in the draft, and Apply writes it. A shortcut that breaks a rule of the date range picker is disabled. The date range picker ships no list of shortcuts: “Last 30 days” and “This quarter” depend on your product’s calendar.

09
01
2026
09
30
2026

Locale and format

locale takes a BCP 47 tag and sets the order, separators and placeholders of both fields, the month and weekday names in the calendar, the dates in the head of the panel, and the dates the calendar button announces. There is no format string: each locale writes its own shape. Unset, the locale comes from SlottedProvider in React or provideSlotted in Angular, and falls back to en-US. The value stays the same pair of PlainDate objects in every locale.

11
02
2026
12
23
2026
02
11
2026
23
12
2026
02
11
2026
23
12
2026

First day of the week and week numbers

The calendar starts the week on the day the locale uses. firstDayOfWeek overrides it with a number from 0, Sunday, to 6, Saturday. weekNumbers adds a column of ISO 8601 week numbers, and a press on a number chooses its week; ISO weeks start on Monday, so set firstDayOfWeek to 1 to keep each row inside one numbered week.

10
05
2026
10
16
2026

Sprints run two ISO weeks, Monday to Friday.

Controlled

Pass value and update it from onValueChange in React, or bind [value] and update it from (valueChange) in Angular, when other parts of the screen depend on the range. The value is a DateRange, { start, end }, where each end is a PlainDate or null; a range with both ends empty is null. Buttons outside the date range picker can set the value, and both fields and the calendar follow.

09
01
2026
09
30
2026

Statement from 2026-09-01 to 2026-09-30.

Clearing

clearable adds one clear button to the frame while either end holds a date, and Clear to the footer of the panel. It empties both ends with the reason clear and moves focus to the start field. With required, neither is drawn. The two fields do not draw clear buttons of their own.

09
14
2026
09
27
2026

Clear the dates to list orders from any date.

An open end

A range with one end, such as { start, end: null }, is a value: the field shows the start and leaves the end empty, where the reader sees it. Use it for a period with no end yet, such as a price that stays valid until further notice. Open the panel on the end, and the first press writes the missing day.

10
01
2026
mm
dd
yyyy

Leave the end empty for a price with no end date.

Editing one end

The end being edited carries data-current in the frame and is marked in the head of the panel, and the calendar opens on that end’s day. Focusing a field, or pressing an end in the head, makes it the current one. defaultPosition="end" starts on the end, so the first press in the calendar writes the end and keeps the start, which suits extending a booking. position and onPositionChange in React, or [position] and (positionChange) in Angular, control it.

10
05
2026
10
09
2026

Returns 2026-10-09. Open the calendar and press a day to move the return date.

The panel holds a draft: Apply writes it, Clear empties it when the picker is clearable, and Escape or a press outside leaves the value as it was. confirm={false} in React, or confirm="false" in Angular, drops Apply, and the press that closes the range writes it and closes the panel. footer in React and an element with slDateRangePickerFooter in Angular set the text beside the actions; unset, it names the limits.

In a form

In React, startName and endName add two hidden inputs that submit the ends as ISO strings, such as 2026-10-14, whether they were typed or chosen. In Angular, the date range picker is a form control: formControlName, formControl and ngModel bind the whole DateRange, and the date range picker reports slottedDateRangeOrder for an end before its start, slottedDateRangeMin and slottedDateRangeMax for a date outside the bounds, slottedDateRangeUnavailable for an unavailable date and slottedDateRangeLength for a length outside the limits. Validators.required accepts a range with one open end, so this example checks for both ends with its own validator. Submit without dates to see the required error, type an end before the start to see the order error, then reset.

mm
dd
yyyy
mm
dd
yyyy

Error:

Narrow screens

Under 760 pixels, the panel shows one month and the shortcuts become a strip. Under 480 pixels on a touch screen, it opens as a sheet attached to the bottom of the viewport instead of a popover under the frame. The positioner carries data-presentation="sheet".

mm
dd
yyyy
mm
dd
yyyy

Keyboard and the trigger’s name

Alt+ArrowDown opens the calendar from either field and leaves focus in the field, so typing continues. Enter or Space on the calendar button opens it and moves focus to the day of the current end, or to today when that end is empty. Tab and Shift+Tab cycle through the shortcuts, the calendar and the footer until the panel closes. The arrow keys move between days, and the head of the panel says the length of the range the focused day would make; Enter or Space on a day starts the range and, pressed again, completes it. Ctrl+Enter applies. Escape closes the panel, discards the draft, and returns focus to the calendar button; while the calendar shows the month or year grid, Escape first returns to the day grid. The calendar button’s accessible name carries both dates and the length, so a screen reader announces them when focus returns. messages replaces that name: choose while no range is set, and change with its {start}, {end} and {length} slots once one is. onOpenChange in React and (openChange) in Angular report why the calendar opened or closed.

11
26
2026
11
29
2026

Focus either date and press Alt+ArrowDown.

Focus and open from code

The date range picker’s handle has focus(), which puts focus on the first segment of the current end, or of the end you pass: focus('end'). It also has open() and close() in React, named openSurface() and closeSurface() in Angular. Opening from code moves focus into the calendar, as the calendar button does. Reach the handle with ref in React and #picker="slDateRangePicker" in Angular.

04
01
2026
03
31
2027

Defaults for a section

DateRangePickerDefaultsProvider in React and provideDateRangePickerDefaults in Angular set count, months, variant, size, placement, confirm, timeZone, today and calendar once for every date range picker under them, such as a travel booking form. A value set on one date range picker still wins, and inside a field the field’s size wins over the provider’s.

11
09
2026
11
12
2026
11
12
2026
11
14
2026

Reporting period filter for a dashboard

A dashboard filter in the small size, with the shortcuts analysts use most and max at today. The figures recompute from the chosen range, and the comparison uses the period of the same length that ends the day before it starts.

09
24
2026
09
30
2026
Orders shipped
1,621up +4%

from 1,558 previous 7 days

Orders per day
232

over 7 days

Booking a warehouse dock window

A carrier books dock 4 for one to three weekdays. Weekends and the days another carrier holds are unavailable, so once a start is chosen the calendar stops at the next held day; maxLength stops it at three days, and min and max keep the booking inside the open schedule.

mm
dd
yyyy
mm
dd
yyyy

Book 1 to 3 weekdays from October 1. Booked as of Wednesday, September 30, 2026: Oct 7–8 and Oct 21–23.

Comparing two periods

The date range picker holds one range. To compare two periods, use two of them: the second one’s shortcuts are computed from the first, so “Previous period” and “Same period last year” always match the period being analyzed.

09
01
2026
09
30
2026
08
02
2026
08
31
2026

Shortcuts follow the period above.

Accessibility

KeyEffectFocus
Alt+ArrowDownopenstays in the field
Enter, Spaceopenthe cell of the current end, or today when it is empty
Escapeclosetrigger
Tabcontained—
  • The trigger says aria-haspopup="dialog" and its name carries the value written, which is where focus returns when the panel closes.
  • The panel is a dialog with its Tab wrapped, and each grid inside it is one stop.
  • Escape discards the draft and returns focus to the trigger. Ctrl+Enter applies from anywhere in the panel.
  • The footer’s hint is a status region, so the reason Apply is off is spoken as well as drawn.
  • Alt+ArrowDown opens the panel and leaves focus in the field, so the segments keep every key they had.
  • The length between the two halves is a status region, so a reader hears "4 nights" on every arrow as much as they see it on every hover.
  • The half being edited is a tint and a line, so it is told without color.

API

DateRangePicker

Props

valueDateRange | null
The run held, either end of which may be null. Present means the consumer owns it.
defaultValueDateRange | nullDefault null
What it starts from, and returns to on a form reset. Read once.
position'start' | 'end'
The end the next press writes. Present means the consumer owns it.
defaultPosition'start' | 'end'Default start
The end it starts on.
count'days' | 'nights'Default days
What the length counts.
minLengthnumber
The shortest run, in the unit count names.
maxLengthnumber
The longest run, in the unit count names.
contiguousbooleanDefault true
Whether a run may cross an unavailable day.
minPlainDate
The earliest accepted date.
maxPlainDate
The latest accepted date.
isDateUnavailable(date: PlainDate) => boolean
Refuses particular dates.
presetsreadonly PickerPreset<DateRange>[]
The consumer’s own shortcuts.
confirmbooleanDefault true
Whether the panel keeps a draft until Apply.
monthsnumberDefault 2
How many months the panel shows. One below 760 pixels.
weekNumbersbooleanDefault false
Draws the ISO week number, as a press that chooses the week.
fixedWeeksbooleanDefault false
Six rows whatever the months need.
firstDayOfWeeknumberDefault the locale’s
0 is Sunday.
yearPivotnumber
How a two-digit typed year resolves.
calendar'gregory'Default gregory
The calendar system.
startNamestring
The name a form posts the start under.
endNamestring
The name a form posts the end under.
invalidboolean
Stated by the consumer; a run that fails a rule is invalid without it.
openboolean
Whether the panel is showing. Present means the consumer owns it.
defaultOpenbooleanDefault false
Whether it starts open when nobody else says. Read once.
placement'bottom-start' | 'bottom' | 'bottom-end' | 'top-start' | 'top' | 'top-end'Default bottom-start
Where the panel opens, before the positioner has read the room.
size'sm' | 'md' | 'lg'Default md
The height of the control. The field around it answers when the picker does not.
variant'outline' | 'subtle' | 'plain'Default outline
How the control draws its frame.
localestringDefault the language in force
BCP 47. Writes the field, the panel and the trigger’s name.
timeZonestringDefault the runtime’s
Which zone answers "what is now".
todayPlainDateDefault the clock’s
The day it is: the mark of today, and the month an empty panel opens on.
disabledboolean
Answers no key and no press.
readOnlyboolean
Readable and not changeable.
requiredboolean
The form needs a value.
clearablebooleanDefault false
Draws a clear on the control and in the panel, unless required.
messagesPartial<DateRangePickerMessages>
Words laid over the language in force: the trigger’s names, the two ends, what is said of a refused run, and the phrases that count it.

Events

NamePayloadWhen
onValueChange(value: DateRange | null, request: ChangeRequest<DateRange | null>)Before the value moves, and cancellable: from a key in a field, from Apply, from Clear.
onOpenChange(open: boolean, request: ChangeRequest<boolean>)Before the panel opens or closes, with the reason.
onPositionChange(position: DateRangePickerPosition, request: ChangeRequest<DateRangePickerPosition>)Before the end being edited moves.

Composition

DateRangePickerDefaultsProvidercomponent
On applicationSets calendar, confirm, count, months, placement, size, timeZone, today and variant once.
footerReactNodeDefault the limits
What the footer says when nothing is wrong.
render(props: DateRangePickerRootProps) => ReactNode
Substitutes the element the root renders.
refRef<DateRangePickerHandle>
focus(), open() and close().

Parts

PartElementRequiredPurpose
rootdiv, or the element render returnsYesThe frame of the picker. Carries data-ui="date-range-picker", data-count, data-size, data-variant, data-open and the state attributes.
controldivYesThe box the panel hangs from, around the field and the trigger.
triggerbuttonYesThe button that opens the panel. Its name carries both ends and the length written.
startdivYesThe wrapper of the field of the start, with data-current while it is the end being edited.
separatorspanYesThe dash between the two fields.
enddivYesThe wrapper of the field of the end, on the same terms.
clearbuttonNoEmpties both ends, with clearable and a value.

Theming

Each token is a CSS custom property: set it in a theme, or on any element to retune every date range picker inside it.

Date Range Picker tokens

TokenDefault
--slotted-date-range-picker-action-active-backgroundvar(--slotted-tone-secondary-subtle-active)
--slotted-date-range-picker-action-colorvar(--slotted-text-muted, GrayText)
--slotted-date-range-picker-action-hover-backgroundvar(--slotted-tone-secondary-subtle-hover)
--slotted-date-range-picker-action-sizemin( calc(var(--_icon-size) + 2 * var(--slotted-space-2, 0.25rem)), calc(var(--_height) - var(--_border-width) * 2 - var(--slotted-space-2, 0.25rem)) )
--slotted-date-range-picker-backgroundvar(--slotted-control-surface, Field)
--slotted-date-range-picker-border-colorvar(--slotted-control-border-color, ButtonBorder)
--slotted-date-range-picker-colorvar(--slotted-text, CanvasText)
--slotted-date-range-picker-current-colorvar(--slotted-tone-accent-solid)
--slotted-date-range-picker-current-size2px
--slotted-date-range-picker-disabled-backgroundvar(--slotted-disabled-background)
--slotted-date-range-picker-disabled-border-colorvar(--slotted-disabled-border)
--slotted-date-range-picker-disabled-colorvar(--slotted-disabled-foreground)
--slotted-date-range-picker-hover-border-colorvar(--slotted-tone-accent-border)
--slotted-date-range-picker-invalid-border-colorvar(--slotted-tone-danger-border)
--slotted-date-range-picker-invalid-edge-widthvar(--slotted-control-invalid-edge-width, 1px)
--slotted-date-range-picker-invalid-focus-ring-colorvar(--slotted-focus-ring-color-invalid, Highlight)
--slotted-date-range-picker-plain-hover-backgroundvar(--slotted-tone-secondary-subtle-hover)
--slotted-date-range-picker-radiusvar(--slotted-control-radius, 4px)
--slotted-date-range-picker-readonly-backgroundvar(--slotted-tone-secondary-subtle-hover)
--slotted-date-range-picker-separator-colorvar(--slotted-text-muted, GrayText)
--slotted-date-range-picker-shadowvar(--slotted-control-shadow, none)
--slotted-date-range-picker-subtle-backgroundvar(--slotted-surface-sunken, Canvas)
--slotted-date-range-picker-subtle-border-colorvar(--slotted-border-subtle, ButtonBorder)
--slotted-date-range-picker-subtle-hover-backgroundvar(--slotted-tone-secondary-subtle-hover)

Theme tokens it reads

TokenDefault
--slotted-border-subtleSet per scheme by the theme
--slotted-control-border-colorSet per scheme by the theme
--slotted-control-border-widthvar(--slotted-border-width-thin)
--slotted-control-font-familyvar(--slotted-font-family-sans)
--slotted-control-font-size-lgcomfortable 14px · compact 13px · dense 12px
--slotted-control-font-size-mdcomfortable 13px · compact 12px · dense 12px
--slotted-control-font-size-smcomfortable 12px · compact 12px · dense 12px
--slotted-control-gap-lgcomfortable 8px · compact 6px · dense 6px
--slotted-control-gap-mdcomfortable 8px · compact 6px · dense 4px
--slotted-control-gap-smcomfortable 6px · compact 4px · dense 4px
--slotted-control-height-lgcomfortable 38px · compact 32px · dense 30px
--slotted-control-height-mdcomfortable 34px · compact 28px · dense 26px
--slotted-control-height-smcomfortable 30px · compact 26px · dense 24px
--slotted-control-icon-size-lgcomfortable 18px · compact 16px · dense 14px
--slotted-control-icon-size-mdcomfortable 16px · compact 14px · dense 13px
--slotted-control-icon-size-smcomfortable 14px · compact 13px · dense 12px
--slotted-control-invalid-edge-widthvar(--slotted-border-width-thin)
--slotted-control-padding-inline-lgcomfortable 16px · compact 12px · dense 10px
--slotted-control-padding-inline-mdcomfortable 13px · compact 10px · dense 8px
--slotted-control-padding-inline-smcomfortable 10px · compact 8px · dense 6px
--slotted-control-radiusvar(--slotted-radius-sm)
--slotted-control-shadowSet per scheme by the theme
--slotted-control-shadow-focus-geometry0 1px 4px -1px
--slotted-control-surfaceSet per scheme by the theme
--slotted-control-transition-durationvar(--slotted-duration-short)
--slotted-control-transition-easingvar(--slotted-easing-standard)
--slotted-disabled-backgroundSet per scheme by the theme
--slotted-disabled-borderSet per scheme by the theme
--slotted-disabled-foregroundSet per scheme by the theme
--slotted-focus-ring-colorSet per scheme by the theme
--slotted-focus-ring-color-invalidSet per scheme by the theme
--slotted-focus-ring-offsetvar(--slotted-border-width-thick)
--slotted-focus-ring-widthvar(--slotted-border-width-thick)
--slotted-radius-none0px
--slotted-radius-xs2px
--slotted-space-10.125rem
--slotted-space-20.25rem
--slotted-surface-sunkenSet per scheme by the theme
--slotted-target-comfortable44px
--slotted-target-min24px
--slotted-textSet per scheme by the theme
--slotted-text-mutedSet per scheme by the theme
--slotted-tone-accent-borderSet per scheme by the theme
--slotted-tone-accent-solidSet per scheme by the theme
--slotted-tone-danger-borderSet per scheme by the theme
--slotted-tone-secondary-subtle-activeSet per scheme by the theme
--slotted-tone-secondary-subtle-hoverSet per scheme by the theme