shadcn.io is not affiliated with official shadcn/ui
Framework
UI library
Radix UI does not include this primitive, so this page uses the Ark UI component. The visuals match the Ark UI version.
Installation
bunx --bun shadcn@latest add https://kit.dev/r/radix/date-picker.jsonAnatomy
DatePickerRoot
├── DatePickerClearTrigger
├── DatePickerContent
│ └── DatePickerPositioner
├── DatePickerLabel
├── DatePickerMonthSelect
├── DatePickerNextTrigger
├── DatePickerPresetTrigger
├── DatePickerPrevTrigger
├── DatePickerRangeText
├── DatePickerTable
│ ├── DatePickerTableBody
│ ├── DatePickerTableCell
│ │ └── DatePickerTableCellTrigger
│ ├── DatePickerTableHead
│ ├── DatePickerTableHeader
│ └── DatePickerTableRow
├── DatePickerView
│ ├── DatePickerViewControl
│ └── DatePickerViewTrigger
└── DatePickerYearSelectUsage
import { ChevronDownIcon } from "lucide-react";
import { Button } from "@/components/ui/button";
import {
CalendarNextTrigger,
CalendarPrevTrigger,
CalendarTable,
CalendarTableDays,
CalendarViewControl,
CalendarViewDate,
CalendarWeekDays,
} from "@/components/ui/calendar";
import {
DatePicker,
DatePickerContent,
DatePickerTrigger,
DatePickerValue,
} from "@/components/ui/date-picker";<DatePicker>
<DatePickerTrigger asChild>
<Button
className="w-[212px] justify-between font-normal"
variant="outline"
>
<DatePickerValue placeholder="Pick a date" />
<ChevronDownIcon aria-hidden="true" data-icon="inline-end" />
</Button>
</DatePickerTrigger>
<DatePickerContent>
<CalendarViewControl>
<CalendarPrevTrigger />
<CalendarViewDate />
<CalendarNextTrigger />
</CalendarViewControl>
<CalendarTable>
<CalendarWeekDays />
<CalendarTableDays />
</CalendarTable>
</DatePickerContent>
</DatePicker>Accessibility
| Key | Description |
|---|---|
Enter | Activate the focused control. |
Space | Activate the focused control. |
Demos
Basic
A basic date picker component.
Range
A date picker component for selecting a range of dates.
Dob
A date picker for selecting a date of birth, with month and year dropdowns.
Input
A date picker component with an input field for selecting a date.
Time
A date picker component with a time input field for selecting a time.
Natural Language
Parse natural language dates in the input and keep a calendar for picking.
Rtl
Right-to-left date picker. See the RTL configuration guide for document direction.
API Reference
DatePicker
PropType
AttributeType
DatePickerContent
div
PropType
AttributeType
CSS variableType
--transform-originstringDatePickerControl
div
PropType
AttributeType
DatePickerInput
input
PropType
className?stringAttributeType
DatePickerPositioner
div
PropType
AttributeType
CSS variableType
--transform-originstringDatePickerPresetTrigger
button
PropType
AttributeType
DatePickerTrigger
button
PropType
AttributeType
DatePickerTimer
PropType
AttributeType
DatePickerValue
span
PropType
AttributeType
useDatePicker
PropType