Introducing PrimeReact v11-alpha 🎉Discover Now

DatePicker

DatePicker is a form component to work with dates.

Pick your departure and return dates · Free cancellation
preview

Installation#

npx shadcn@latest add https://v11.primereact.org/r/datepicker.json

Usage#

import { DatePicker, DatePickerBody, DatePickerCalendar, DatePickerInput, DatePickerPanel, DatePickerPopup, DatePickerPortal, DatePickerPositioner } from '@/components/ui/datepicker';
<DatePicker value={date} onValueChange={(e) => setDate(e.value)}>
    <DatePickerInput />
    <DatePickerPortal>
        <DatePickerPositioner>
            <DatePickerPopup>
                <DatePickerBody>
                    <DatePickerPanel>
                        <DatePickerCalendar />
                    </DatePickerPanel>
                </DatePickerBody>
            </DatePickerPopup>
        </DatePickerPositioner>
    </DatePickerPortal>
</DatePicker>

Examples#

Basic#

A simple date selector.

basic-demo

Range#

Use selectionMode="range" to select a start and end date.

range-demo

Multiple#

Use selectionMode="multiple" to select multiple dates independently.

multiple-demo

Format#

Customize the input format with dateFormat.

format-demo

Min / Max#

Restrict the selectable range with minDate and maxDate.

min-max-demo

Month Picker#

Use view="month" to select only month and year.

month-picker-demo

Year Picker#

Use view="year" to select only the year.

year-picker-demo

Time#

Use showTime to render a time picker beneath the calendar; pass hourFormat="12" for AM/PM.

time-demo

Inline#

Skip the popup chain and embed the calendar directly.

SuMoTuWeThFrSa
2627282930311
2345678
9101112131415
16171819202122
23242526272829
303112345
inline-demo

Multiple Months#

Render two side-by-side calendars with numberOfMonths={2} and one DatePickerCalendar per offset.

January0
SuMoTuWeThFrSa
2627282930311
2345678
9101112131415
16171819202122
23242526272829
303112345
February0
SuMoTuWeThFrSa
303112345
6789101112
13141516171819
20212223242526
272812345
March0
SuMoTuWeThFrSa
2627281234
567891011
12131415161718
19202122232425
2627282930311
multiple-months-demo

Show Week Numbers#

Add showWeek to display ISO week numbers on the leftmost column.

show-week-demo

Sizes#

Use size to render small or large variants.

sizes-demo

Fluid#

Use fluid to make the input span the parent container width.

fluid-demo

Filled#

Use variant="filled" for a filled input style.

filled-demo

Disabled#

Use disabled to disable the input.

disabled-demo

Invalid#

Use invalid to display the input in an error state.

invalid-demo

Accessibility#

Screen Reader#

DatePicker uses combobox role on the input and dialog role on the popup. Day cells use gridcell role with aria-selected reflecting selection and range state.

Keyboard Support#

KeyFunction
tabMoves focus through interactive parts
space / enterSelects the focused date
arrow keysMoves focus by day or grid cell
page up/downMoves focus by month
home / endMoves focus to start/end of week
escapeCloses the popup