Skip to content

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

UIComponentsReact

Week Calendar

A month of weeks, each row a week with its number, that the reader moves through with the arrow keys and picks one week from.

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

Rendered by React 19.3.1

week-calendar.tsx

Installation

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

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

Usage

WeekCalendar draws the whole calendar: the previous and next buttons, the month's heading, and a grid whose first column is the week number under a Wk header. Give it a name (aria-label, or a Field label around it). The value is an ISO date string, defaultValue="2026-11-11", read as the first day of its week; onValueChange(value, eventDetails) reports the week's first day, and null means none. weekRule (locale or iso), firstDayOfWeek and minimalDays set how weeks are numbered, locale the language, min and max bound the week's first day, and isWeekDisabled(week) and isWeekUnavailable(week) limit the choice. To lay the calendar out yourself, pass children: WeekCalendarContent is the default content, and each part has its own name (WeekCalendarRow, WeekCalendarWeekNumber, WeekCalendarCell, WeekCalendarDay, …). The keys, the row as the focus holder, the week's name, the form value and the ARIA structure come from the headless Week Calendar.

import {
  WeekCalendar,
  WeekCalendarCell,
  WeekCalendarContent,
  WeekCalendarDay,
  WeekCalendarGrid,
  WeekCalendarGridBody,
  WeekCalendarGridHeader,
  WeekCalendarGridRow,
  WeekCalendarHeaderCell,
  WeekCalendarHeading,
  WeekCalendarNextButton,
  WeekCalendarPrevButton,
  WeekCalendarRow,
  WeekCalendarWeekNumber,
  WeekCalendarWeekNumberHeaderCell,
} from '@/components/ui/week-calendar'

Examples

Default

A month with the current week chosen and today in it.

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

It is the Calendar's look for the root, the buttons, the heading, the weekdays and the days, with the row as the thing chosen: the whole row fills with the primary colour when its week is chosen, and the focus ring (WCAG 2.4.7) is drawn round the row, not a day. The current week has a 2 px bar under its number, a cue that is not only colour (WCAG 1.4.1); today's day keeps the Calendar's muted ground; an unavailable week's days are struck through and a disabled week is drawn at half opacity. The chosen row's day numbers and its days of the neighbouring months are at least 4.5:1 against its fill, and the current week's bar at least 3:1 against the calendar and the chosen row, in every preset theme, light and dark (WCAG 1.4.3, 1.4.11). Rows are 32 px tall, above WCAG 2.5.8's 24 px. The chevrons are lucide's ChevronLeft and ChevronRight, inline, and turn around in a right-to-left page. This item takes Base UI's component ID as its slug and one name per Base UI part, with WeekCalendarContent added.

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