Ballmac UI home

Date Picker

A button that opens a calendar popover to choose one date, with presets, month and year selects, min and max dates, clearing, invalid state and form submission.

We deliver Monday to Friday.

Installation

$ pnpm dlx shadcn@latest add @ballmac/date-picker

Usage

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

The full example is in the Code tab above.

Examples

Birthday, invalid, disabled

API reference

PropTypeDefault
value

Controlled date. Pass `null` for a controlled empty value; `undefined` leaves the picker uncontrolled.

Date | null—
defaultValue

Initial date when uncontrolled.

Date—
onValueChange

Called with the new date, or `undefined` when cleared.

(date: Date | undefined) => void—
placeholder

Text on the trigger when no date is chosen.

string—
locale

Locale for the trigger text and calendar. The default keeps server and browser output identical.

string—
format

Formatting options for the trigger text.

Intl.DateTimeFormatOptions{ dateStyle: "medium" }
minDate

Earliest selectable date.

Date—
maxDate

Latest selectable date.

Date—
presets

Quick picks shown beside the calendar.

DatePickerPreset[]—
clearable

Show a control that clears the date.

booleanfalse
invalid

Mark the field invalid (`aria-invalid`, destructive border).

booleanfalse
name

Name of a hidden input that submits the date as YYYY-MM-DD.

string—
dropdowns

Show month and year selects in the calendar header.

booleanfalse

Also accepts the standard attributes of its root element.

Accessibility

KeyAction
Enter / Space / ArrowDownOpens the calendar from the trigger
Arrow keysMove between days
EscapeCloses and returns focus to the trigger

Use with AI

Give it a defaultValue or value and onValueChange. presets add quick picks, dropdowns adds month and year selects, name submits YYYY-MM-DD. With the shadcn MCP server set up (guide), ask your agent:

Add the Ballmac UI Date Picker (@ballmac/date-picker) to this project with the shadcn MCP, then use it where it fits.

Use it for

  • A single date in a form
  • Deadlines, birthdays and delivery dates
  • When quick picks like Tomorrow help

Not for

  • A date range; use date-range-picker
  • An always-visible calendar; use calendar

Registry JSON: https://ui.ballmac.com/r/date-picker.json

Credits

Free to use in personal and commercial projects.