Calendar
ProNewA 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
| Prop | Type | Default |
|---|---|---|
| mode | "single" | "range"`single` picks one day; `range` picks a start and an end. | "single" |
| value | Date | nullThe selected day, in single mode. | — |
| defaultValue | Date | null | null |
| onValueChange | (date: Date | null) => void | — |
| range | DateRangeThe selected span, in range mode. | — |
| defaultRange | DateRange | { from: null, to: null } |
| onRangeChange | (range: DateRange) => voidRuns on each press: first with only `from`, then with both ends. | — |
| defaultMonth | DateThe month shown first. Defaults to the selection, or the current month. | — |
| min | DateThe earliest and latest days that can be chosen. | — |
| max | Date | — |
| isDateDisabled | (date: Date) => booleanReturn true for days that cannot be chosen, e.g. weekends. | — |
| months | 1 | 2Show two months side by side when the viewport is at least 640px wide. | 1 |
| locale | stringA BCP 47 tag for month and weekday names. Defaults to the browser's language. | — |
| weekStart | 0 | 1The first column: 0 for Sunday, 1 for Monday. | 0 |
| className | string | — |
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.