Skip to content
Focsd homeFocsd homeFocsd
Forms

Calendar

A month grid for picking a date or a range.

  • Tag: focsd-calendar
  • Pattern: Grid (date)
  • Category: Forms

Example

HTML
<focsd-calendar
value="2026-03-14"
min="2026-03-05"
max="2026-04-20"
locale="en-GB"></focsd-calendar>

Events and a legend

events marks days with dots: { date, label, kind?, color?, tone? }, as JSON in the attribute or an array in JS. tone (positive, caution, critical, info) shows in every preset; color is a category hue the colorful Prismatic preset shows. legend lists each kind once.

HTML
<div data-focsd-brand="prismatic">
<focsd-calendar
value="2026-11-26"
locale="en-US"
legend
events='[{"date":"2026-11-03","label":"Team sync","kind":"Meeting","color":"blue"},{"date":"2026-11-10","label":"Team sync","kind":"Meeting","color":"blue"},{"date":"2026-11-07","label":"Launch review","kind":"Deadline","tone":"critical"},{"date":"2026-11-14","label":"Founders day","kind":"Holiday","color":"amber"},{"date":"2026-11-17","label":"Team sync","kind":"Meeting","color":"blue"},{"date":"2026-11-17","label":"Design critique","kind":"Review","color":"violet"},{"date":"2026-11-21","label":"Q4 plan due","kind":"Deadline","tone":"critical"}]'></focsd-calendar>
</div>

Usage

Import the module once, then use the tag like any HTML element. Every framework below renders the same element; see Frameworks for setup.

<script type="module">
import '@focsd-dev/components/focsd-calendar.js';
</script>
<focsd-calendar value="2026-03-14" min="2026-03-05" max="2026-04-20" locale="en-GB"></focsd-calendar>

API

Attributes

AttributePropertyTypeDefault
valuevaluestring—
minminstring—
maxmaxstring—
rangerangebooleanfalse
value-startvalueStartstring—
value-endvalueEndstring—
localelocalestring—
eventseventsCalendarEvent[][]
legendlegendbooleanfalse

Methods

MethodDescription
focusDay()Move keyboard focus to the active day (used by date pickers when their dialog opens).
select(iso)Choose a date; in range mode the first pick sets the start, the second the end.

Events

EventDescription
changeFired when the user commits a change to the value or state.

CSS parts

Style the inside of the component with ::part(), for example focsd-calendar::part(day).

PartDescription
dayEach day cell.
gridThe grid element.
headerThe header element.
headingThe heading element.
navBoth month buttons.
nextThe next month button.
padAn empty cell before the first or after the last day of the month.
previousThe previous month button.
range-edgeAdded to the first and last day of a selected range.
selectedAdded to selected days.
todayAdded to today's date.
weekdayA weekday column header.
eventsThe markers under a day with events.
eventOne event marker (in a day or the legend).
legendThe list of event kinds, with `legend`.
legend-itemOne event kind in the legend.

Accessibility

  • APG date grid: role="grid" labeled by the month heading, which is a polite live region.
  • Each day has a full accessible name ("Saturday, 14 March 2026"), aria-selected, aria-current="date" for today, and aria-disabled outside min/max.
  • One tab stop (roving tabindex); arrows are mirrored in right-to-left pages. The first day of the week comes from the locale.

Keyboard

KeyAction
Arrow keysPrevious / next day or week
Page Up / DownPrevious / next month
Shift + Page Up / DownPrevious / next year
Home / EndStart / end of the week
Enter / SpaceSelect the day

Events and a legend

  • The dots are decorative: each day's accessible name includes its events and their kinds ("Tuesday, November 17, 2026, Team sync (Meeting), Design critique (Review)"), and a tooltip shows them on hover, so nothing depends on color.
  • The legend is a list labeled "Event types" (localizable as calendarLegend).
  • Up to three dots show per day; every event is still named in the label.