DitherCharts

Calendar

Updated

Calendar is a month grid in pixel ink, for one date or a range. Arrows move a day or a week, Page Up and Down change the month, and Enter picks. Dates are "YYYY-MM-DD" strings, so no time zone can shift a day. Like the charts, it takes your theme's ink and paper, light or dark, and needs no Tailwind.

Example

import "@/components/dithercharts/controls.css"
import { Calendar } from "@/components/dithercharts/calendar"

<Calendar
  defaultValue="2026-10-14"
  min="2026-10-05"
  // Weekends off; the dates are UTC, so this is the same day everywhere.
  isDateDisabled={(date) => [0, 6].includes(new Date(date).getUTCDay())}
  onValueChange={(date) => setDay(date)}
/>
// A start and an end, as { from, to }.
<Calendar mode="range" weekStartsOn={1} onValueChange={setRange} />

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 calendar

Props

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

Calendar props
PropTypeDefaultDescription
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 calendar; pair it with onValueChange.
value.fromType stringDefault –
value.toType stringDefault –
defaultValueType string | DateRangeDefault –The date (or range) chosen at first, for an uncontrolled calendar.
defaultValue.fromType stringDefault –
defaultValue.toType stringDefault –
onValueChangeType ((value: string) => void) | ((value: DateRange) => void)Default –Called with the chosen date, or the range so far in range mode.
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 first column: 0 is Sunday, 1 Monday, and so on.
localeType stringDefault the browser'sThe BCP 47 locale for month and day names.
classNameType stringDefault –