Skip to content

Date picker

Choose a date from a familiar Material calendar.

Installation

Terminal
pnpm dlx shadcn@latest add https://react-toolbox.io/r/date-picker.json

New here? Set up your project first. Styles, fonts, and required components are included.

Usage

Values are Date objects, bounded by minDate and maxDate. In the calendar, arrow keys move by day or week, Home/End move within the week, and PageUp/PageDown move by month (hold Shift for years).

Composition

CalendarSelection supports single, multiple and range values, multiple months, week numbers, unavailable-day predicates and clearing. Keyboard focus moves independently from selection.

October 2026
October 2026
WeekMTWTFSS
40
1
2
3
4
41
5
6
7
8
9
10
11
42
12
13
14
15
16
17
18
43
19
20
21
22
23
24
25
44
26
27
28
29
30
31
November 2026
WeekMTWTFSS
44
1
45
2
3
4
5
6
7
8
46
9
10
11
12
13
14
15
47
16
17
18
19
20
21
22
48
23
24
25
26
27
28
29
49
30

Choose a visit range. Sundays are unavailable.

Show composition code
tsx
'use client';
import { useState } from 'react';
import { CalendarSelection, type DateRange } from '@/components/ui/material/date-picker';

export default function CalendarComposition() {
  const [range, setRange] = useState<DateRange>({ from: undefined, to: undefined });
  return (
    <div>
      <CalendarSelection
        mode="range"
        value={range}
        onValueChange={setRange}
        defaultMonth={new Date(2026, 9, 1)}
        numberOfMonths={2}
        showWeekNumbers
        clearable
        isDateUnavailable={(date) => date.getDay() === 0}
        excludeUnavailable
      />
      <p role="status" className="mt-4 text-toolbox-body">
        {range.from
          ? `${range.from.toLocaleDateString()}${range.to ? ` – ${range.to.toLocaleDateString()}` : ' – choose an end date'}`
          : 'Choose a visit range. Sundays are unavailable.'}
      </p>
    </div>
  );
}

State and callbacks

  • Use value/onChange, or defaultValue for internal state and form reset. The dialog edits a draft until confirmation; autoOk confirms a day selection immediately.
  • Visibility is internal by default. Use defaultOpen to initialize it or open/onOpenChange to control it. When controlled, update open from onOpenChange; onDismiss reports dismissal.

API reference

Key props and defaults. Full types and inline documentation are included with the source in material/date-picker.

DatePicker

Property Type Default
autoOk boolean —
clearable boolean

Show a clear action. Controlled consumers clear by setting value to null.

—
defaultOpen boolean —
defaultValue Date —
disabledDates readonly Date[] —
endYear number —
labels Partial<DatePickerLabels> —
layout 'portrait' | 'landscape' | 'responsive'

Preserve portrait, force landscape, or adapt to wide landscape viewports.

—
locale DatePickerLocale 'en'
maxDate Date —
minDate Date —
onChange (date: Date, event?: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>) => void —
onOpenChange (open: boolean) => void —
open boolean —
readOnly boolean

Keep the value focusable and submitted while preventing edits and validation.

—
startYear number —
value Date | null —

Material guidelines

  • Use a calendar when the relationship between days helps someone choose a date. Distinguish today from the selected day.
  • Keep selection provisional until confirmation, with clear Cancel and OK actions. Disable unavailable dates consistently.

Material Design 1: Pickers