Month Picker
Pick a month, or a year: billing periods, reports and card expiry.
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
value | string | — | The month picked, as YYYY-MM, or the year as YYYY with granularity="year". |
granularity | 'month' | 'year' | month | Pick a month, or only a year. |
min | string | — | The earliest month (or year) that can be picked, in the same format as value. |
max | string | — | The latest month (or year) that can be picked, in the same format as value. |
name | string | — | Form field name: the form receives the value under it. |
required | boolean | false | Asks for a value before the form submits. |
disabled | boolean | false | Turns the picker off; the value is kept and, as for a disabled form control, not submitted. |
label | string | — | The accessible name of the picker. Inside a c2-form-field, the field's label names it. |
Events
| Name | Type | Description |
|---|---|---|
input | Event | Fired when the user picks a month (or year), before change. Read value. |
change | CustomEvent<{ value: string }> | Fired after the user picks a month (or year). Not fired for programmatic changes. |
CSS parts
Shadow DOM styling hooks used with ::part(name). Prefer CSS custom properties when they cover the change.
| Name | Description |
|---|---|
header | The row with the paging buttons and the title. |
title | The title button: the year, or the range of years. |
navigation | A paging button. |
grid | The grid of months or years. |
cell | A month or a year. |
CSS custom properties
Grouped by semantic target and state from --c2-<component>__<target>__<state>--<property>. Click a group to collapse it; click a name to copy it.
| Name | Type | Default | Description |
|---|---|---|---|
--c2-month-picker--background | color | #ffffff | |
--c2-month-picker--color | color | #18181b | |
--c2-month-picker--border | border | 1px solid #e4e4e7 | |
--c2-month-picker--border-radius | border-radius | 14px | |
--c2-month-picker--box-shadow | box-shadow | none | |
--c2-month-picker--padding | padding | 12px | |
--c2-month-picker--width | pixel | 264px | |
--c2-month-picker--font-size | font-size | 14px | |
--c2-month-picker__title--font-weight | font-weight | 600 | |
--c2-month-picker__navigation--size | pixel | 32px | |
--c2-month-picker__navigation__hover--background | color | #f4f4f5 | |
--c2-month-picker__grid--gap | pixel | 4px | |
--c2-month-picker__cell--height | pixel | 40px | |
--c2-month-picker__cell--border-radius | border-radius | 999px | |
--c2-month-picker__cell__hover--background | color | #f4f4f5 | |
--c2-month-picker__cell__current--color | color | #0265dc | The current month (or year). |
--c2-month-picker__cell__current--font-weight | font-weight | 600 | |
--c2-month-picker__cell__selected--background | color | #0265dc | |
--c2-month-picker__cell__selected--color | color | #ffffff | |
--c2-month-picker__cell__disabled--opacity | opacity | 0.38 | |
--c2-month-picker__focus--outline | outline | 2px solid rgba(2, 101, 220, 0.4) | |
--c2-month-picker__error--border | border | 1px solid #dc2626 | Shown while an enclosing c2-form-field shows an error. |
Text and languages
The text the component shows, in English. It shows another language when the app adds one with addTranslations, under month-picker, and the nearest lang asks for it; any message not translated stays in English. {0}, {1}… stand for the values a message carries. Languages guide.
| Key | English | Values |
|---|---|---|
label | Choose a month | — |
yearLabel | Choose a year | — |
previousYear | Previous year | — |
nextYear | Next year | — |
previousYears | Previous years | — |
nextYears | Next years | — |
chooseYear | {0}, choose a year | {0} year |
backToMonths | Back to the months of {0} | {0} year |
valueMissing | Please choose a month. | — |
yearMissing | Please choose a year. | — |