Skip to content
Ballpoint

Date Picker

A button that shows the chosen date and opens a calendar to change it: a popover, a calendar and a button, put together.

From shadcn/ui

Installation

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

Usage

tsx
import { DatePicker } from "@/components/ui/date-picker"

<DatePicker value={date} onValueChange={setDate} />

Examples

Date range

Two months in the popup; it closes once both ends are picked.

In a form

A label, a hint and a dropdown calendar for a date far from today.

Your age is worked out from this, and never shown.

API reference

value / defaultValue / onValueChange
Date | undefined

The chosen date, controlled or not. Make the Dates in a client component or from strings: one a server component passes arrives as the same instant, which can be another day in the browser's time zone.

placeholder
default "Pick a date"
string

Shown until a date is chosen.

format
(date: Date) => string

How the date is written on the button. The default is long, in `locale`.

locale
default "en-US"
string

Names in the calendar, and the way the default format writes the date.

DateRangePicker value / onValueChange
{ from?: Date; to?: Date }

The same for two dates.

Calendar props
disabled, startMonth, endMonth, weekStartsOn, captionLayout…

Passed to the Calendar in the popup.

seed
string | number

Pins the drawing.