Skip to content

DateRangePicker

Chooses a span made of a start and an end day. Two calendars sit side by side, and the span previews under the pointer before the second click lands.

tsx
import { DateRangePicker } from 'neba';

<DateRangePicker label="Stay" startPlaceholder="Check in" endPlaceholder="Check out" clearable />;

Props

PropTypeDefaultDescription
variantshared'solid' | 'outline' | 'text''outline'Weight of the surface: filled, hairline, or none
sizeshared'xs' | 'sm' | 'md' | 'lg' | 'xl''md'Height and type scale
colorshared'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'info''primary'Semantic colour role. Arbitrary colour values are not accepted
densityshared'default' | 'compact''default'Padding only: never the height, never the type scale
elevationshared0 | 1 | 2 | 30Drop shadow depth. 0 means no shadow at all
valueDateRange | nullThe chosen range, as { start, end } with either end possibly null
defaultValueDateRange | nullThe initial range, for an uncontrolled picker
onValueChange(value: DateRange) => voidAlways called with an object. A cleared range is { start: null, end: null }
defaultMonthDateWhich month the calendar opens on when there is no value. Defaults to this one
minDateDate | nullThe earliest day that may be chosen, in both panels
maxDateDate | nullThe other end of the same span
shouldDisableDate(date: Date) => booleanBlocks individual cells inside the range: weekends, holidays, a room already booked. The cell stays in the grid, unavailable, and the callback is handed the value that cell would produce
weekStartsOnshared0 | 1 | 2 | 3 | 4 | 5 | 6Which day the week starts on, Sunday being 0. Defaults to whatever the locale says
monthCount1 | 22How many months are on screen at once. Two by default, because a range that crosses a month boundary is the ordinary case
startPlaceholderReactNodeShown in the first half of the trigger while the start is unchosen
endPlaceholderReactNodeThe same, for the end
presetsreadonly DateRangePreset[]Shortcuts listed beside the calendars: "Last 7 days", "This month". A function value is computed when it is pressed
openbooleanWhether the popup is open. Use with onOpenChange for a controlled one
defaultOpenbooleanfalseWhether it starts open
onOpenChange(open: boolean) => voidCalled when the popup opens or closes
localestringBCP 47 tag deciding the month and weekday names, the order of the header's two buttons, and how the trigger writes the value. Defaults to the browser's
formatIntl.DateTimeFormatOptionsHow the trigger writes the value. Passed straight to Intl
clearablebooleanfalseOffers the × that empties the control
closeOnSelectbooleantrueCloses the popup once both ends are chosen
labelsPartial<PickerLabels>The strings a screen reader hears. One object rather than twenty props, because they are a set: they default to the locale’s wording, and the date names are not among them, those come from Intl
namestringIdentifies the field when a form is submitted. Two hidden inputs of the same name, so the ends arrive as FormData.getAll(name)
fullWidthbooleanfalseStretches to the width of the container
labelReactNodeThe label, wired to the control by Base UI's Field
descriptionReactNodeHelper text
errorReactNodeError message. Its presence turns the control invalid and re-points the colour family at danger
invalidboolean!!errorForces the invalid state without a message, for when a form library owns validity
readOnlybooleanfalseShown but not changeable. Keeps its colour and edge, drains the saturation
disabledbooleanfalseUnavailable. Drops the colour family for neutral grey

Native <div> attributes pass through to the root. Only color, defaultValue and children are excluded, since the table above spells them differently.

The value is a single object rather than a tuple.

ts
interface DateRange {
  start: Date | null;
  end: Date | null;
}

onValueChange is always called with an object, so a cleared range is { start: null, end: null } and there is never a second kind of empty to test for.

The half state between the first and second click is reported as { start, end: null }, and closing the popup without a second click throws it away. A second click that lands before the first is not an error: it is the same range in the other order, so the ends are sorted.

The remaining props (minDate · maxDate · shouldDisableDate · variant · size) behave as they do on DatePicker.

Examples

monthCount

Defaults to 2. The two panels are one calendar in halves: the left has no forward stepper, the right has no back stepper, and either header moves the pair.

With two panels, the leading and trailing days of neighbouring months are not drawn, so the same date never appears in both panels at once.

presets

Puts common spans beside the popup as buttons. A preset's value may be a range object or a function returning one. Prefer the function: a range computed once at render time is wrong for anyone who left the tab open.

name

name renders two hidden inputs of the same name, so both ends submit together.

ts
const form = new FormData(event.currentTarget);
const [start, end] = form.getAll('stay'); // '2026-07-03', '2026-07-09'

Both are local YYYY-MM-DD, the shape a native <input type="date"> submits.

Accessibility

  • Each panel is a role="grid" with a tab stop of its own, so Tab moves between the two grids rather than through eighty-four cells.
  • Only the two ends carry aria-selected; the days between them get the band and nothing else.
  • The popup footer says which end the next click will fill.

Released under the MIT License