DitherCharts

Date picker

Updated

DatePicker is a select-style field that opens a Calendar in the dithered popup, for one date or a range. It shows the date in the reader's locale and submits "YYYY-MM-DD". Like the charts, it takes your theme's ink and paper, light or dark, and needs no Tailwind.

Example

Pick a launch date

import "@/components/dithercharts/controls.css"
import { DatePicker } from "@/components/dithercharts/date-picker"

<DatePicker label="Due" name="due" min="2026-10-01" onValueChange={setDue} />
<DatePicker
  label="Period"
  mode="range"
  name="period" // submits period-from and period-to
  onValueChange={({ from, to }) => setPeriod({ from, to })}
/>

Install

Controls install with DitherCharts Pro. See Installation to log in, then import controls.css once, e.g. in your root layout.

npx dithercharts add date-picker

Props

It renders a native element, so every other attribute that element takes passes through.

DatePicker props
PropTypeDefaultDescription
labelrequiredType ReactNodeDefault –The caption above the field, and its accessible name.
placeholderType stringDefault "Pick a date"Shown while nothing is chosen.
nameType stringDefault –The form field name: the date's hidden input, or ${name}-from and ${name}-to for a range.
disabledType booleanDefault false
collisionPaddingType { top?: number; bottom?: number }Default 8 eachSpace in px the popup keeps clear at the window's top and bottom, e.g. a sticky header's height. It opens on the side with more room.
classNameType stringDefault –
modeType "single" | "range"Default –"single" (the default) picks one date; "range" picks a start and an end, the value becoming a DateRange.
valueType string | DateRangeDefault –The chosen date as "YYYY-MM-DD" (a DateRange in range mode), for a controlled picker; pair it with onValueChange.
defaultValueType string | DateRangeDefault –The date (or range) chosen at first, for an uncontrolled picker.
onValueChangeType ((value: string) => void) | ((value: DateRange) => void)Default –Called with the chosen date, or in range mode with the range once both ends are picked.
minType stringDefault –The earliest date that can be chosen, as "YYYY-MM-DD".
maxType stringDefault –The latest date that can be chosen, as "YYYY-MM-DD".
isDateDisabledType (date: string) => booleanDefault –Rules out other dates, e.g. weekends.
weekStartsOnType 0 | 1 | 2 | 3 | 4 | 5 | 6Default 0The calendar's first column: 0 is Sunday, 1 Monday, and so on.
localeType stringDefault the browser'sThe BCP 47 locale for the field's date and the calendar's names.
hintType ReactNodeDefault –Help text under the field, read after its label.
errorType ReactNodeDefault –An error under the field; it also marks the field invalid.