Fragiola

API: components

MonthCalendar

A grid of the 12 months of a year for choosing one month, with the calendar's keys mapped to months and the month names from Intl.

A grid of the 12 months of a year for choosing one month: a card's expiry, a reporting month. A range of months is a MonthRangeCalendar, a page of years a YearCalendar, a month in a popup a MonthPicker.

A month is a plain { year, month } (PlainYearMonth), with no day and no time zone, from the toolkit's @fragiola/primitives/month-year, which only the month and year entries import. The grid is the WAI-ARIA APG grid pattern with the Calendar's keys mapped to months; the names come from Intl for the locale.

Behaviour

  • Page: 12 months in rows of columns (default 3, so 4 rows); paging never shifts the rows.
  • Focus: the grid is one tab stop, the focused month's cell. It starts at the value, else the month holding today, kept inside min and max.
  • Keyboard: the arrows move one month and one row (left and right swap in right-to-left), Home and End go to the row's ends, Page Up and Page Down one page (a year); Enter and Space choose. Moving off the page shows the next one, its cell taking the focus within the same key.
  • Bounds: months outside min / max are disabled (never focused); unavailable ones (isUnavailable) can be focused, not chosen. PrevButton and NextButton keep the focus and are disabled when the next page holds only disabled months.
  • Names: a month cell reads its long name ("November", a word of its name, WCAG 2.5.3) and is named "November 2026"; the Heading is the year; the consumer can replace each one.
  • Calendar systems: with calendar={persian} (from @fragiola/primitives/calendar-systems) the items are the system's months, a page one of its years (13 months in a Hebrew leap year), or its years; the values are the system's ({ year: 1405, month: 8 }), and a form submits the first day's ISO date with the system, 2026-10-23[u-ca=persian].
  • In a picker or a view: with no value of its own it binds to a MonthPicker or to a CalendarView.

Anatomy

partelementdata-primitives-partrole
Rootdivmonth-calendar-rootholds the state
Headingh2month-calendar-headingthe year shown (it names the grid)
PrevButtonbuttonmonth-calendar-prev-buttonshows the previous page
NextButtonbuttonmonth-calendar-next-buttonshows the next page
Gridtablemonth-calendar-gridthe page
GridBodytbodymonth-calendar-grid-bodyits rows
Rowtrmonth-calendar-rowone row
Celltdmonth-calendar-cellone month

Usage

import { MonthCalendar, type PlainYearMonth } from "@fragiola/primitives-react/month-calendar";

const [value, setValue] = useState<PlainYearMonth | null>(null);

<MonthCalendar.Root value={value} onValueChange={setValue} locale="en-US">
    <MonthCalendar.PrevButton aria-label="Previous year">‹</MonthCalendar.PrevButton>
    <MonthCalendar.Heading />
    <MonthCalendar.NextButton aria-label="Next year">›</MonthCalendar.NextButton>
    <MonthCalendar.Grid>
        <MonthCalendar.GridBody>
            {(row) => (
                <MonthCalendar.Row key={row[0]?.year} row={row}>
                    {(item) => <MonthCalendar.Cell key={JSON.stringify(item)} value={item} />}
                </MonthCalendar.Row>
            )}
        </MonthCalendar.GridBody>
    </MonthCalendar.Grid>
</MonthCalendar.Root>;

GridBody and Row render their default parts when given no children.

Props

Every part also takes what the primitive contract gives. The names below are React's; Vue binds them the same way (v-model:value, @value-change), and Angular as inputs and outputs ([(value)], (valueChangeDetails)).

Root

proptypedefaultdescription
valuePlainYearMonth | nullthe chosen month, controlled
defaultValuePlainYearMonth | nullnullthe initial month, uncontrolled
onValueChange(value: PlainYearMonth | null, details: { reason }) => voidevery choice (reason item-press)
minPlainYearMonth | nullmonths before it are disabled
maxPlainYearMonth | nullmonths after it are disabled
isUnavailable(month: PlainYearMonth) => booleanunavailable months can be focused, not chosen
localestringthe document's langa BCP 47 tag: the names
calendarCalendarSystemthe ISO calendara calendar system: the items are its months (a page is one of its years: 12 or 13 months), and so are the values (a form submits the first day's ISO date, 2026-10-23[u-ca=persian])
columnsnumber3items per row
disabledbooleanfalsenothing can be focused or chosen
readOnlybooleanfalsemonths can be focused, not chosen

Heading

No props of its own: its text is the year (a month calendar) or the page's span of years (a year calendar), from Intl, unless it has children.

PrevButton

No props of its own.

NextButton

No props of its own.

Grid

No props of its own.

GridBody

No props of its own: React's children are a function of each row, Vue's default slot gets { row }, Angular's rows() lists them.

Row

proptypedefaultdescription
row (react, vue)PlainYearMonth[] | PlainYear[]its items; Angular loops over the row itself

Cell

proptypedefaultdescription
valuePlainYearMonth | PlainYearits month or year; its name is the full name from Intl unless it has an aria-label

State and part attributes

partattributes
Rootdata-disabled, data-readonly
Headingan id, aria-live="polite"
PrevButton, NextButtontype="button", aria-controls (the grid), disabled and data-disabled when they cannot move
Gridrole="grid", aria-labelledby (the Heading), aria-readonly, aria-disabled
Cellrole="gridcell", aria-label, tabindex (0 on the focused item, -1 on the others), aria-selected, aria-disabled, aria-current="date" (the item holding today); data-today, data-selected, data-disabled, data-unavailable

Keyboard

keymoves the focused item to
ArrowRight / ArrowLeftthe next / previous item (swapped in right-to-left)
ArrowDown / ArrowUpthe item below / above (columns items on)
Home / Endthe first / last item of its row
PageDown / PageUpthe same place on the next / previous page (a year)
Enter, Spacechooses it
Escapein a range calendar with a started range, cancels it

Exports

entryexports
@fragiola/primitives-react/month-calendarChangeDetails, ChangeReason, MonthCalendar, MonthCalendarCellProps, MonthCalendarCellState, MonthCalendarGridBodyProps, MonthCalendarGridProps, MonthCalendarHeadingProps, MonthCalendarHeadingState, MonthCalendarItem, MonthCalendarNextButtonProps, MonthCalendarPageButtonState, MonthCalendarPrevButtonProps, MonthCalendarRootProps, MonthCalendarRootSharedProps, MonthCalendarRootState, MonthCalendarRowProps, PlainYear, PlainYearMonth, RenderProp, YearMonthRange, YearRange
@fragiola/primitives-vue/month-calendarChangeDetails, ChangeReason, MonthCalendar, MonthCalendarCellProps, MonthCalendarCellState, MonthCalendarGridBodySlots, MonthCalendarGridProps, MonthCalendarHeadingProps, MonthCalendarHeadingState, MonthCalendarItem, MonthCalendarNextButtonProps, MonthCalendarPageButtonState, MonthCalendarPrevButtonProps, MonthCalendarRootEmits, MonthCalendarRootProps, MonthCalendarRootSharedProps, MonthCalendarRootState, MonthCalendarRowProps, MonthCalendarRowSlots, PlainYear, PlainYearMonth, RenderSlotProps, YearMonthRange, YearRange
@fragiola/primitives-angular/month-calendarChangeDetails, ChangeReason, MONTH_CALENDAR, MONTH_CALENDAR_BINDING, MonthCalendarBinding, MonthCalendarCell, MonthCalendarCellState, MonthCalendarComponent, MonthCalendarGrid, MonthCalendarGridBody, MonthCalendarHeading, MonthCalendarInputs, MonthCalendarItem, MonthCalendarKind, MonthCalendarMode, MonthCalendarNextButton, MonthCalendarNextButtonState, MonthCalendarOptions, MonthCalendarPrevButton, MonthCalendarPrevButtonState, MonthCalendarRoot, MonthCalendarRootBase, MonthCalendarRow, MonthCalendarState, MonthCalendarUnits, MonthCalendarValue, PlainYear, PlainYearMonth, ValueChangeEvent, YearMonthRange, YearRange, isItemRange, unitsOf