UIComponentsReact
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
Installation
npx shadcn@4.23.0 add https://hamur.dev/r/react/year-calendar.jsonIt 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
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.