Skip to content
EspañolEnglish
All components (204)

Month and year

Dates and time · MonthPicker · .amset-monthpicker

What it is and when to use it

A month and year picker: a dropdown with the twelve months, written in the active language, and a four-digit field for the year. The value is a string, 2026-10, which is what an <input type="month"> and the server understand.

When to use it

  • Reports, filters and accounting closings: wherever a month is needed and not a day.
  • onChange only fires with a full month and a full year, and the year has to be between minYear and maxYear (1900 and 2100 by default).
  • With name it travels in a native form as a single field.

When not to

  • A specific day: DatePicker. A period of dates: DateRangePicker.

Keyboard: that of Select for the month and that of a text field for the year, which only accepts digits.

Accessibility: it is a fieldset with a legend; "Month" and "Year" name each part. The year error appears when leaving the field and is linked to it.

Fine styling: --amset-monthpicker-gap (gap between month and year), plus the field variables (--amset-field-*).

What it looks like

Card expiry
January
February
March
April
May
June
July
August
September
October
November
December

The card expires on 2028-04.

<MonthPicker label="Card expiry" value={mes} onChange={setMes} minYear={2026} maxYear={2040} />

Props

Import it with import { MonthPicker } from '@amset/ui'. Required props are marked.

PropTypeWhat it does
labelrequiredstringRequired: names the month and year group.
classNamestringMerged with the library classes; it does not replace them.
disabledboolean—
errorstringError from outside (from the server). It takes precedence over the one the field calculates.
hintstring—
initialValuestring | nullThe value at start, not controlled from outside.
maxYearnumberThe last year accepted. 2100 by default.
minYearnumberThe first year accepted. 1900 by default.
namestringSo that it travels in a native form, as a single field.
onChange(value: string) => voidNotifies only with a complete month AND year: `YYYY-MM`.
requiredboolean—
size"sm" | "md" | "lg"—
valuestring | nullThe month and year, `YYYY-MM`, controlled from outside. `null` means empty.
variantFieldVariant—

It also accepts the attributes of the element it renders: className, style, data-*, aria-* and its events.

CSS variables

These CSS variables are how you adapt it. Declare them on the component's selector, not on :root: the stylesheet redeclares them in the rule itself, and a declaration on the same element always wins.

VariableDefault
--amset-monthpicker-gapvar(--amset-space-3)

How to change it

.amset-monthpicker {
  --amset-monthpicker-gap: ...;
}

In the test bench

Every state and variant, to try one at a time, on its page at ui.amset.tech: