MonthPicker

Language:

Default

With Month Navigation

Constrained Range (2024-01 to 2027-06)

Only months between January 2024 and June 2027 are selectable.

Small Size

Disabled

MonthPicker

A year/month picker with popover. The user selects a year from a dropdown and a month from a button grid.

Usage

import { MonthPicker } from "@/components/ui/month-picker"

<MonthPicker
  value={value}
  onChange={setValue}
/>

// With month navigation arrows
<MonthPicker
  value={value}
  onChange={setValue}
  enableMonthNavigation
/>

// Constrained range
<MonthPicker
  value={value}
  onChange={setValue}
  minDate={{ year: 2020, month: 0 }}
  maxDate={{ year: 2030, month: 11 }}
/>

Props

PropTypeDefaultDescription
value{ year: number; month: number } | undefinedSelected value. month is 0-indexed (0 = January, 11 = December).
onChange(value: { year: number; month: number } | undefined) => voidCalled when a month is selected.
enableMonthNavigationbooleanfalseAdds < > buttons beside the trigger to step one month forward or backward.
placeholderstringCustom placeholder text. Defaults to a localized string.
disabledbooleanfalseDisables the trigger button.
language"en" | "pt""en"Locale for labels and month names.
size"default" | "sm""default"Trigger size variant.
shadow"none" | "xs" | "sm""xs"Shadow on the trigger button.
minDate{ year: number; month: number }Earliest selectable year/month. Defaults to 100 years before the current year.
maxDate{ year: number; month: number }Latest selectable year/month. Defaults to 10 years after the current year.
triggerClassNamestringAdditional classes for the trigger button.
classNamestringAdditional classes for the popover content.