Skip to content

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

UIComponentsReact

Month Range Picker

Two fields the reader types a start month and an end month into, with a button that opens a month calendar in a popup to pick the range from.

Built on the headless Month Range Picker.See its API in Docs

Rendered by React 19.3.1

month-range-picker.tsx

Installation

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

It also adds utils, button, month-calendar, month-picker, popover. The app needs its setup first: Installation.

Usage

The parts are the Month Picker's with a start and an end: put two MonthRangePickerInputs in the MonthRangePickerControl, type="start" and type="end", with a MonthRangePickerSeparator between them (an en dash by default), then MonthRangePickerClear and MonthRangePickerTrigger. The popup is a MonthRangePickerPortal, MonthRangePickerPositioner, MonthRangePickerPopup and MonthRangePickerCalendar, which picks the range in two presses. The value is { start, end }, '2026-11' strings, or null. An end typed before the start is not swapped: the end field is marked invalid and the picker's value is null until it is fixed. The rest is the headless Month Range Picker's.

import {
  MonthRangePicker,
  MonthRangePickerCalendar,
  MonthRangePickerClear,
  MonthRangePickerClose,
  MonthRangePickerControl,
  MonthRangePickerInput,
  MonthRangePickerPopup,
  MonthRangePickerPortal,
  MonthRangePickerPositioner,
  MonthRangePickerPreset,
  MonthRangePickerSegment,
  MonthRangePickerSeparator,
  MonthRangePickerTrigger,
} from '@/components/ui/month-range-picker'

Examples

Default

Two inputs with a dash between them and a year.

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

This item follows the Date Range Picker's composition. It takes the Month Picker's control, segment, trigger, popup, preset and close classes, so the item requires it; the calendar is the Month Calendar's markup on the range Root.

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 Range Picker's API reference.