Collapsible date field with a portaled Calendar panel, locale-aware trigger formatting, and spring open motion.
npx shadcn@latest add @iconiq/date-picker"use client";
import { useState } from "react";
import { DatePicker } from "@/components/ui/date-picker";
export function DatePickerPreview() {
const [value, setValue] = useState<Date | null>(new Date());
return (
<DatePicker onChange={setValue} value={value} />
);
}valueControlled selected date. When provided, the trigger and embedded Calendar both reflect this value.
Type Date | null
defaultValueInitial selected date for uncontrolled usage when `value` is omitted.
Type Date | null·Default null
placeholderCopy shown in the trigger when no date is selected.
Type string·Default Select a date
onChangeCalled when the user picks or clears a date from the embedded Calendar or clear control.
Type (date: Date | null) => void
classNameOptional class names applied to the outer wrapper.
Type string
defaultOpenWhether the Calendar panel starts expanded on first render.
Type boolean·Default false
openControlled open state for the Calendar panel. Pair with `onOpenChange`.
Type boolean
onOpenChangeCalled when the panel opens or closes from the trigger, selection, Escape, or outside click.
Type (open: boolean) => void
disabledDisables the trigger and prevents the panel from opening.
Type boolean·Default false
clearableShows a clear button when a date is selected so users can reset to `null`.
Type boolean·Default false
closeOnSelectWhether picking a date closes the panel automatically.
Type boolean·Default true
dateFormatdate-fns format string for the trigger label. Uses `calendarProps.locale` when provided.
Type string·Default EEE, MMM d, yyyy
nameOptional form field name. Renders a hidden input with the selected ISO date.
Type string
idOptional id applied to the trigger button.
Type string
aria-invalidMarks the trigger as invalid for assistive tech and applies error styling.
Type boolean
sidePreferred panel side relative to the trigger. Flips when there is not enough space.
Type "top" | "bottom"·Default bottom
alignHorizontal alignment of the portaled panel to the trigger.
Type "start" | "end"·Default start
calendarPropsProps forwarded to the embedded Calendar, such as size, locale, disabled, bounds, modifiers, weekStartsOn, minYear, and maxYear. Range mode is not supported on DatePicker.
Type Omit<CalendarProps, 'selected' | 'defaultSelected' | 'onSelect' | 'month' | 'onMonthChange' | 'mode' | 'range' | 'defaultRange' | 'onRangeSelect'>
Install the exact registry entry shown on the right when you want the component file and its declared runtime dependencies together.
Dependencies: @base-ui/react/input, motion, lucide-react, date-fns.
Registry dependency: calendar. Install date-picker together with the shared Calendar component.
The generated registry file is /r/date-picker.json.
Contact
Additionally, if you find any bug or issue, feel free to raise an issue.