Skip to content

Early previewhamur is not on npm yet. The components are being built in the open, follow along on GitHub.

UIComponentsReact

Calendar

A month of days the reader moves through with the arrow keys or the previous and next buttons, and picks one day or several from.

Built on the headless Calendar.See its API in Docs

Rendered by React 19.3.1

calendar.tsx

Installation

npx shadcn@4.23.0 add https://hamur.dev/r/react/calendar.json

It also adds utils, button. The app needs its setup first: Installation.

Usage

Calendar draws the whole calendar: the previous and next buttons, a heading and a grid for each visible month, and a day in each cell. Give it a name (aria-label), since a calendar on a page needs one to tell it from the next. The value is an ISO date string, defaultValue="2026-11-12", or with multiple a list of them, and onValueChange(value, eventDetails) reports it; null means none. min, max, isDateDisabled(date) and isDateUnavailable(date) limit the choice, visibleMonths shows several months side by side, firstDayOfWeek and locale (a BCP 47 string such as fr-FR) set the week and the language, and fixedWeeks always draws six rows. buttonVariant is the previous and next buttons' Button variant, ghost by default, and showOutsideDays turns off the days of the neighbouring months. To lay the calendar out yourself, pass children: CalendarContent is the default content (months is the number of grids, the same as visibleMonths), and CalendarDayButton is the day inside a cell. Give the Root views (['day', 'month', 'year']) and the heading gets a button beside it that switches to a grid of months and then of years (CalendarViewTrigger, CalendarMonthGrid, CalendarYearGrid, CalendarMonth and CalendarYear); without views the markup is the one of version 0.1.0. The keys, the pending dates, the form value and the ARIA structure come from the headless Calendar.

import {
  Calendar,
  CalendarContent,
  CalendarDayButton,
  CalendarMonth,
  CalendarMonthGrid,
  CalendarViewTrigger,
  CalendarYear,
  CalendarYearGrid,
} from '@/components/ui/calendar'

Examples

Default

A month with no day chosen, in a bordered box.

Its preview and code are at the top of the page.

Differences from shadcn's, which draws the days of a date library's picker:

- **Values are strings, not Dates.** selected and onSelect(date) are value, defaultValue and onValueChange(value, eventDetails), over '2026-11-12'; mode="multiple" is multiple, and mode="range" is the separate Range Calendar item. shadcn's disabled matcher is isDateDisabled, with min and max for startMonth and endMonth; month, defaultMonth and onMonthChange are visibleMonth, defaultVisibleMonth and onVisibleMonthChange, over '2026-11'; numberOfMonths is visibleMonths; weekStartsOn is firstDayOfWeek; locale is a string, not a locale object. today and timeZone are new: pass today to render the same on the server and the client. - Not carried over: captionLayout (the heading is a label with no month or year dropdown; views adds month and year grids instead), showWeekNumber, formatters, components and classNames. Style a part by composing children, or pass className to the calendar. - **CalendarDayButton is not a button.** The cell is the grid's focus holder, as the ARIA Authoring Practices' date picker has it, so the day inside it is a span that only draws the state: it has the cell's data-selected, data-today, data-disabled, data-unavailable and data-outside-month. CalendarContent is new. - Disabled days cannot be focused or chosen; an unavailable one can hold focus, is struck through and cannot be chosen. The previous and next buttons are aria-disabled at min and max and keep focus. - Each day and each button is at least 32 by 32 CSS pixels.

The chevrons are lucide's ChevronLeft and ChevronRight, inline, and turn around in a right-to-left page.

API reference

The styled parts pass every prop to the headless part they wrap and add classes. The props, data attributes and keyboard are on Calendar's API reference.