Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Calendar

ProNew

A month grid for one day or a range, one or two months wide, with disabled days and no date library.

Installation

pnpm dlx shadcn@latest add @viewport/calendar

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above comes with Truffle Pro.

Props

PropTypeDefault
mode"single" | "range"

`single` picks one day; `range` picks a start and an end.

"single"
valueDate | null

The selected day, in single mode.

—
defaultValueDate | nullnull
onValueChange(date: Date | null) => void—
rangeDateRange

The selected span, in range mode.

—
defaultRangeDateRange{ from: null, to: null }
onRangeChange(range: DateRange) => void

Runs on each press: first with only `from`, then with both ends.

—
defaultMonthDate

The month shown first. Defaults to the selection, or the current month.

—
minDate

The earliest and latest days that can be chosen.

—
maxDate—
isDateDisabled(date: Date) => boolean

Return true for days that cannot be chosen, e.g. weekends.

—
months1 | 2

Show two months side by side when the viewport is at least 640px wide.

1
localestring

A BCP 47 tag for month and weekday names. Defaults to the browser's language.

—
weekStart0 | 1

The first column: 0 for Sunday, 1 for Monday.

0
classNamestring—

Accessibility

  • A grid with roving focus: arrow keys by day and week, Page Up and Down by month, Shift for years, Home and End.
  • Each day is named in full, and today and disabled days are stated.
  • Month and weekday names follow the locale; the week can start on Monday.
  • The month slides only when motion is allowed.