Skip to content

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

UIComponentsReact

Month Calendar

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

Built on the headless Month Calendar.See its API in Docs

Rendered by React 19.3.1

month-calendar.tsx

Installation

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

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

Usage

MonthCalendar draws the whole calendar: the previous and next buttons, a heading with the year and a button that switches to a page of years, and a grid of the twelve months. Give it a name (aria-label). The value is a '2026-11' string, or with multiple a list of them, and onValueChange(value, eventDetails) reports it; null means none. min, max, isMonthDisabled(month) and isMonthUnavailable(month) limit the choice, visibleYears shows several years side by side, columns sets the months in a row, and locale sets the language. buttonVariant is the previous and next buttons' Button variant, ghost by default. Pressing a year in the year grid returns to its months. To lay the calendar out yourself, pass children: MonthCalendarContent is the default content (years is the number of grids, the same as visibleYears), and each part has its own name. The keys, the views, the form value and the ARIA structure come from the headless Month Calendar.

import {
  MonthCalendar,
  MonthCalendarCell,
  MonthCalendarContent,
  MonthCalendarGridBody,
  MonthCalendarGridRow,
  MonthCalendarHeading,
  MonthCalendarMonth,
  MonthCalendarMonthGrid,
  MonthCalendarNextButton,
  MonthCalendarPrevButton,
  MonthCalendarViewTrigger,
  MonthCalendarYear,
  MonthCalendarYearGrid,
} from '@/components/ui/month-calendar'

Examples

Default

A year of months with none chosen, in a bordered box.

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

shadcn has no month calendar. This item draws the Calendar's box, buttons and heading around a grid of month buttons: the chosen month is filled with the primary color, the current month has a short bar under its name, a year that holds the chosen month has a dot in the year grid, and an unavailable one is struck through. The cell is the grid's focus holder and the month inside it only draws the state. The button beside the heading turns its chevron over while the year grid shows. This item takes Base UI's component ID as its slug and one name per Base UI part.

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 Month Calendar's API reference.