calendar-tsx

Parts

Every part, its model prop and its element.

Every part renders one element with data-scope='calendar', a data-part name, state attributes and its geometry as --cal-* custom properties; custom themes lists them. Parts render your children, accept any props of their element plus render, and forward ref.

All parts must render inside CalendarProvider or Calendar.

Day grid

PartModel propElementNotes
DayGridViewmodeldivRegion labelled "Calendar". Contains sections.
DayGridViewSectionsectiondivrole='grid'; emits --cal-columns, data-month, and data-resource-id.
DayGridViewSectionHeadernonedivConsumer-supplied month or resource label.
DayGridViewHeadernonedivrole='row'.
DayGridViewHeaderCellcolumndivrole='columnheader', data-weekday, data-resource-id.
DayGridViewRowrowdivrole='row'; emits column and stack counts.
DayGridViewDaydaydivrole='gridcell', data-today, data-outside, data-weekday, data-unavailable, data-resource-id.
DayGridViewDayTriggercalendar, day, viewbuttonNavigates through calendar to view on this date.
DayGridViewRowEventsegmentbuttonA bar across the row's visible columns; data-all-day, data-multi-day.
DayGridViewRowBackgroundEventsegmentdivAn all-day background span; aria-hidden.
DayGridViewDayBackgroundbackgrounddivA background layer's shading; aria-hidden.
DayGridViewOverflowdaybuttonRenders only when day.hasMore.

Render each section's header and rows inside DayGridViewSection, and bars inside their row beside its day cells.

The default theme lays sections out in a responsive grid: --calendar-section-min-width (default 20rem) sets the minimum section width and --calendar-section-gap (default 1rem) the gap. Override them, or style the root's grid, for another arrangement.

For a year overview, use groupBy: 'month' with fixedWeekCount: true. Calendar-only multi-month grids emit data-multi-month, and the supplied themes give them compact rows, centered headings and padded month panels. --calendar-section-gap also sets their spacing (defaults 2rem between columns, 1.5rem between rows). With section and weekday headers present, CSS subgrid aligns neighboring months' header and week tracks. The root's --cal-month-rows is the largest section row count. Resource grids and single months keep their usual sizing.

Time grid

PartModel propElementNotes
TimeGridViewmodeldivrole='region', labelled "Time grid". Scrolls.
TimeGridViewHeadernonedivSticky column headers.
TimeGridViewColumnHeadercolumndivdata-today, data-weekday, data-unavailable, data-resource-id.
TimeGridViewColumnTriggercalendar, column, viewbuttonNavigates through calendar to view on the column's date.
TimeGridViewAllDaynonedivRender it only when allDay is set.
TimeGridViewAllDayEventsegmentbuttonA bar segment; data-all-day, data-multi-day.
TimeGridViewAllDayBackgroundEventsegmentdivaria-hidden. Render it before the bars.
TimeGridViewBodymodeldivHolds the axis and the columns. Emits --cal-slot-units for the grid height.
TimeGridViewAxisnonedivOptional.
TimeGridViewAxisLabelslotdivslot is the time slot, not the HTML attribute. Emits --cal-start, --cal-span.
TimeGridViewColumncolumndivdata-today, data-weekday, data-unavailable.
TimeGridViewBackgroundEventsegmentdivaria-hidden. Render it before the events.
TimeGridViewBackgroundbackgrounddivaria-hidden. A background layer's shading.
TimeGridViewEventsegmentbuttonPlaced by time and lane; data-overlap when it shares lanes, data-short when isShort.
TimeGridViewNowIndicatorcolumndivaria-hidden. Renders only in today's column.

Give the root a height, such as max-block-size: 40rem, to scroll inside the page instead of showing all 24 hours.

TimeGridViewUnavailable takes an unavailable segment and shades it; see the resource view.

List

PartModel propElementNotes
ListViewmodeldivrole='region', labelled "Event list".
ListViewSectionsectionsectiondata-date or data-resource-id; supply an accessible label for grouped sections.
ListViewSectionHeadersectionh2Consumer-supplied date or resource heading.
ListViewDaydaysectiondata-date, optional data-resource-id.
ListViewDayHeaderdayh3
ListViewEventeventbutton
ListViewEmptynonedivRenders only when the list has no days.

Timeline

PartModel propElementNotes
TimelineViewmodeldivrole='region', labelled "Timeline". Scrolls both ways. --cal-slot-columns sizes header slots.
TimelineViewHeadernonedivSticky; holds the day headers and the slot labels.
TimelineViewDayHeaderdaydivdata-today, data-date, data-weekday.
TimelineViewDayTriggercalendar, day, viewbuttonNavigates through calendar to view on the day. See day triggers.
TimelineViewSlotLabelslotdivslot is the time slot, not the HTML attribute.
TimelineViewBodynonedivHolds the rows and the now indicator.
TimelineViewRowrowdivdata-unavailable, data-resource-id.
TimelineViewResourcerowdivThe resource cell; sticks to the start edge.
TimelineViewResourceTogglecalendar, rowbuttonExpands/collapses descendants; aria-expanded, default label; omitted for leaves.
TimelineViewLanerowdivHolds the row's unavailable time and events.
TimelineViewUnavailablesegmentdivaria-hidden.
TimelineViewBackgroundbackgrounddivaria-hidden, data-layer, data-kind; render inside TimelineViewLane.
TimelineViewBackgroundEventsegmentdivaria-hidden, continuation flags; render inside TimelineViewLane.
TimelineViewEventsegmentbuttondata-all-day, data-multi-day, data-continues-before, data-continues-after.
TimelineViewNowIndicatormodeldivaria-hidden. Renders only while now is inside the range.

The parts render no slot cells; themes draw the slot lines as a background of each lane.

Rows expose data-depth, data-parent-id and data-expanded. Resource cells expose data-depth, data-expanded and --cal-resource-depth. Themes indent each level by --calendar-resource-indent (1rem by default); override that token to change the spacing. Toggle icons inherit the theme's text color and focus style.

With one slot per day, omit the slot-label row; the date header is enough. For subday slots, include minutes in the labels. The examples put the full event dates and times in title and aria-label, so clipped bar text stays available.