Month Picker
Pick a month, or a year: billing periods, reports and card expiry.
c2-month-picker picks a month the way a billing page or a report filter does: a year with its twelve months, paging buttons to move through the years, and a title that opens a grid of years to jump further. Its value is YYYY-MM, as a native month input gives, or YYYY with granularity="year".
Import
import '@c2n/components/month-picker'Usage
Value
value is the month picked as YYYY-MM, or the year as YYYY with granularity="year"; anything else is ignored. A click, or Enter or Space on the focused month, picks it and fires input then change (with detail.value). Month names follow the page’s language.
Limits
min and max, in the same format as the value (a bare year also works in month mode), disable the months outside them and stop the paging buttons at the first and last year that has one, as a card-expiry field would with this year and ten years ahead.
Years
In month mode the title shows the year; pressing it opens a grid of twelve years, and picking one there opens its months without changing the value. With granularity="year" the picker shows only the grid of years, and a year is the value.
In a form
Under a name, the form receives the value. required asks for one. Inside a c2-form-field, the field’s label names the picker and its hint and error describe it.
Keyboard
The months are a grid with one tab stop. The arrow keys move by month and by row, running on into the previous or next year at the ends; Home and End go to the start and end of a row; Page Up and Page Down change the year (or the page of years); Enter or Space picks. The current month is marked, and a screen reader hears each month with its year.