Skip to content
Date & Time

Date Picker

Popover-based date selection.

Import

tsx
import { DatePicker } from "@cooud-ui/ui";
bash
npx cooud-ui add date-picker

Examples

API Reference

Generated from the component's exported types.

DatePickerProps

Extends Omit< ButtonHTMLAttributes<HTMLButtonElement>, "value" | "defaultValue" | "onChange" | "disabled" | "name" >

Skip DatePickerProps props table
PropTypeDefaultDescription
value
DateControlled selected date. Pair with `onValueChange`.
defaultValue
DateInitial date for uncontrolled usage.
onValueChange
(date: Date | undefined) => voidCalled with the new date (`undefined` when deselected) on every selection change.
onChange
(date: Date | undefined) => voidLegacy change callback, fired with the same payload as `onValueChange`.
open
booleanControlled open state of the calendar popover. Pair with `onOpenChange`.
defaultOpen
booleanfalseInitial open state for uncontrolled usage.
onOpenChange
(open: boolean) => voidCalled whenever the popover opens or closes.
placeholder
string"Pick a date"Text shown on the trigger when no date is selected.
disabled
booleanfalseDisables the trigger entirely.
invalid
booleanfalseMarks the trigger invalid (error border/ring + `aria-invalid`).
min
DateEarliest selectable day (inclusive).
max
DateLatest selectable day (inclusive).
disabledDates
Matcher | Matcher[]Extra non-selectable days, merged with `min`/`max`.
locale
Locale`date-fns` locale used for both the trigger label and the calendar.
dateFormat
string"PPP"`date-fns` format token for the trigger label.
formatValue
(date: Date) => stringFull override for the trigger label. Wins over `dateFormat`/`locale`.
name
stringForm field name — renders a hidden input with the local `yyyy-MM-dd` date.
align
ComponentPropsWithoutRef<typeof PopoverContent>["align"]"start"Alignment of the popover against the trigger.
contentClassName
stringExtra classes for the popover content.