Search documentation

Search the documentation and open a page.

A date picker component for selecting dates and date ranges.

Loading...

Installation

pnpm dlx shadcn@latest add @wirekyt/date-picker

Composition

DatePicker ├── DatePickerLabel (optional) ├── DatePickerInput │ ├── DatePickerTrigger (optional) │ └── DatePickerClearTrigger (optional) ├── DatePickerControl │ └── DatePickerTrigger │ └── DatePickerValueText (button-style alternative) └── DatePickerContent ├── DatePickerDayView | DatePickerDualMonthDayView │ └── DatePickerSelectHeader ├── DatePickerMonthView └── DatePickerYearView

Examples

Default

Loading...

Input

Loading...

Range

Loading...

Date of Birth

Loading...

API Reference

DatePicker

PropTypeDefaultDescription
idstring | undefined—Unique identifier used to connect the component parts.
localestring | undefined—Locale used to format and parse dates.
createCalendar((identifier: CalendarIdentifier) => Calendar) | undefined—Creates the calendar system used by the picker.
translationsIntlTranslations | undefined—Accessible labels for the picker controls.
idsElementIds | undefined—Overrides generated identifiers for individual parts.
namestring | undefined—Name used when submitting the value with a form.
timeZonestring | undefined—Time zone used when converting and formatting values.
disabledboolean | undefinedfalseDisables interaction with the component.
readOnlyboolean | undefinedfalsePrevents changes while preserving focus and navigation.
requiredboolean | undefinedfalseMarks the associated form control as required.
invalidboolean | undefined—Marks the associated form control as invalid.
outsideDaySelectableboolean | undefined—Allows days outside the visible month to be selected.
minDateValue | undefined—Earliest selectable date.
maxDateValue | undefined—Latest selectable date.
closeOnSelectboolean | undefinedtrueCloses the popup after a selection is completed.
openOnClickboolean | undefined—Opens the popup when the input is clicked.
valueDateValue[] | undefined—Selected dates when controlled.
defaultValueDateValue[] | undefined—Initially selected dates when uncontrolled.
focusedValueDateValue | undefined—Focused calendar date when controlled.
defaultFocusedValueDateValue | undefined—Initially focused calendar date.
numOfMonthsnumber | undefined—Number of months represented by the calendar state.
startOfWeeknumber | undefined—First weekday, from 0 for Sunday through 6 for Saturday.
fixedWeeksboolean | undefined—Always renders six calendar weeks.
showWeekNumbersboolean | undefined—Includes week numbers in the calendar state.
onValueChange((details: ValueChangeDetails) => void) | undefined—Runs when the selected value changes.
onFocusChange((details: FocusChangeDetails) => void) | undefined—Runs when the focused date changes.
onViewChange((details: ViewChangeDetails) => void) | undefined—Runs when the day, month, or year view changes.
onVisibleRangeChange((details: VisibleRangeChangeDetails) => void) | undefined—Runs when the visible date range changes.
onOpenChange((details: OpenChangeDetails) => void) | undefined—Runs when the popup opens or closes.
isDateUnavailable((date: DateValue, locale: string) => boolean) | undefined—Marks dates that cannot be selected.
selectionMode"single" | "multiple" | "range" | undefined—Determines how dates are selected.
maxSelectedDatesnumber | undefined—Limits selections in multiple mode.
format((date: DateValue, details: LocaleDetails) => string) | undefined—Formats values for the input and value text.
parse((value: string, details: LocaleDetails) => DateValue | undefined) | undefined—Parses typed input into a date value.
placeholderstring | undefined—Placeholder used by the default formatter.
view"day" | "month" | "year" | undefined—Current calendar view when controlled.
defaultView"day" | "month" | "year" | undefined—Initial calendar view.
minView"day" | "month" | "year" | undefined—Most detailed view available.
maxView"day" | "month" | "year" | undefined—Broadest view available.
positioningPositioningOptions | undefined—Configures popup placement and collision handling.
openboolean | undefined—Whether the popup is open when controlled.
defaultOpenboolean | undefined—Initial open state when uncontrolled.

DatePickerInput

PropTypeDefaultDescription
indexnumber | undefined—Selects the start or end input for a range.
fixOnBlurboolean | undefined—Restores a valid formatted value when focus is lost.
showTriggerboolean | undefinedtrueShows the calendar trigger inside the input group.
showClearboolean | undefinedfalseShows a clear action when the input has a value.
sizenumber | "default" | "lg" | "xl" | undefineddefaultSets the input group or native input size.

Context, Hooks, and Types

ExportAPI
DatePickerContextRender-prop component that exposes component state and actions.
DatePickerRootProviderProvides an externally created API to the component tree.
useDatePickerCreates or accesses the component API.
useDatePickerContextReturns the nearest component API.
DatePickerValueChangeDetailsType for the details object passed to onValueChange.
DatePickerOpenChangeDetailsType for the details object passed to onOpenChange.

Utilities and Supporting Types

ExportAPI
CalendarDateRepresents a calendar date without a time or time zone.
DateValueDate value type accepted by the picker.
getLocalTimeZoneReturns the current local IANA time-zone identifier.
parseDateParses an ISO YYYY-MM-DD string into a calendar date.