Skip to content

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

UIComponentsReact

Year Calendar

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

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

Rendered by React 19.3.1

year-calendar.tsx

Installation

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

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

Usage

YearCalendar draws the previous and next buttons, a heading with the page's first and last year, and a grid of years. Give it a name (aria-label). The value is a '2026' string, or with multiple a list of them, and onValueChange(value, eventDetails) reports it; null means none. min, max, isYearDisabled(year) and isYearUnavailable(year) limit the choice, yearsPerPage (12 by default) and columns set the page, and locale sets the language. buttonVariant is the previous and next buttons' Button variant, ghost by default. To lay the calendar out yourself, pass children: YearCalendarContent is the default content, and each part has its own name. The keys, the form value and the ARIA structure come from the headless Year Calendar.

import {
  YearCalendar,
  YearCalendarCell,
  YearCalendarContent,
  YearCalendarGridBody,
  YearCalendarGridRow,
  YearCalendarHeading,
  YearCalendarNextButton,
  YearCalendarPrevButton,
  YearCalendarYear,
  YearCalendarYearGrid,
} from '@/components/ui/year-calendar'

Examples

Default

A page of twelve years with none chosen.

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

shadcn has no year calendar. This item draws the Month Calendar's cells with years in them: the chosen year is filled with the primary color, the current year has a short bar under it and an unavailable one is struck through. 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 Year Calendar's API reference.