Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

calendar-wc

Standalone calendar display with events, multi-select, range picking, date constraints, form integration, multi-month view, and expressive theming.

Overview

The <calendar-wc> component displays a month grid for viewing events, availability, or annotations on dates. It supports single, range, and multi-date selection, date constraints, form integration via ElementInternals, multi-month display, and locale-aware rendering.

Attributes

Attribute Type Default Description
data-month number (1-12) current Month to display. Observed: changing it re-renders. The component reflects the visible month back here as you navigate.
data-year number current Year to display. Observed, and reflected like data-month.
data-events JSON — Event data keyed by start ISO date. Values: string, object { label, color, icon, time, end, days }, or array. See Multi-day events. Observed: changing it re-renders and fires calendar-wc:events-changed with source: 'attribute'.
data-selection string "none" Selection mode: "none", "single", "range", or "multi".
data-disabled-dates string — Comma-separated ISO dates to disable.
data-highlight-dates string — Comma-separated ISO dates to highlight, optionally with :category.
data-size string "default" Size variant: "compact", "default", or "large".
data-min-date ISO date — Earliest selectable/navigable date.
data-max-date ISO date — Latest selectable/navigable date.
data-months number (1-12) 1 Number of months to display side by side.
data-year-range number (0-200) 10 Years listed either side of the current year in the year select. data-min-date and data-max-date bound a side instead, and the displayed year is always listed. Use a larger range for birth dates or archives.
data-heading-level number (1-6) — In multi-month views, render each month title as <h1>–<h6> at this level. Without it the titles are plain text (each grid is still labelled by its month), because the component cannot know where it sits in your page outline.
data-label-prev, data-label-next, data-label-year, data-label-close string English Accessible names for the previous/next buttons, the year select, and the day-detail close button. See Localization.
data-label-more string "+{n} more" Large-view overflow text; {n} is replaced with the hidden event count.
name string — Form field name. When set with a selection mode, the calendar participates in native form submission.

data-month, data-year and data-events are observed. The other attributes are read when the element connects (and again if it is moved or re-inserted); change them, then call refresh() or re-insert the element.

Selection Modes

Single selection

Click a date to select it. Fires calendar:select with the selected ISO date.

Range selection

Click two dates to define a range. A hover preview shows between start and cursor. The value uses ISO 8601 interval format: YYYY-MM-DD/YYYY-MM-DD. During selection, the host element gets a data-tentative attribute with the start date.

Multi-select

Click dates to toggle them on or off. Selected dates are returned as space-separated ISO strings.

Date Constraints

Use data-min-date and data-max-date to constrain navigation and disable out-of-range dates. Navigation buttons and the year dropdown respect these boundaries. Constraints work alongside data-disabled-dates and the isDateDisallowed callback — all three are additive.

Multi-Month Display

Set data-months (1–12) to show multiple months in a responsive grid. Navigation shifts by one month at a time. All features (selection, events, highlights) work across all visible months.

Grid Layouts

The grid adapts its column count based on the number of months. On narrow containers, columns reduce responsively.

data-monthsLayoutUse case
22 columnsRange picker
33 columnsQuarter preview
42×2 gridQuarter view
63×2 gridHalf-year
124×3 gridYearly overview

Form Integration

When a name attribute is set and a selection mode is active, the calendar participates in native form submission via ElementInternals. No hidden input needed.

JavaScript Properties

PropertyTypeDescription
.value string | null Selected value. ISO date (single), ISO interval (range), space-separated ISOs (multi), or null.
.isDateDisallowed (date: Date) => boolean Callback to dynamically disable dates. Called per cell during render. Additive with attribute-based constraints.
.getDayParts (date: Date) => string | string[] | null Inject custom data-day-part attributes per cell for CSS targeting.
.events { [iso]: Event[] } | Event[] Live event data. Accepts the date-keyed object that data-events uses, OR a flat array of events with a date field (auto-grouped). Triggers re-render and fires calendar-wc:events-changed with source: 'property'. Reading always returns the date-keyed shape. Once set, a later reconnect does not re-read data-events over it.

Methods

MethodDescription
refresh() Re-render the current view. Setting .isDateDisallowed, .getDayParts or .events already re-renders; call this when the data a callback reads has changed.

Reactive events (JS-first)

See the Data API concepts guide for the dual-mode contract.

isDateDisallowed

getDayParts

Return a string or array of strings to add as data-day-part on the cell's <td>. Style with attribute selectors in CSS.

Events

Event Detail Description
calendar:select { value, date } (single), { value, start, end } (range), { values, dates } (multi) Fired when selection changes.
calendar:navigate { year, month } Fired on month navigation.
calendar:day-open { date, events } Fired when day detail overlay opens (display-only mode).
calendar-wc:events-changed { events, source } Fired after the event data changes. source is 'property' (the .events setter) or 'attribute' (data-events changed).
calendar-wc:upgraded — Fired once the calendar has rendered (every connect).

Size Variants

Three sizes adapt the calendar to different contexts.

SizeMax WidthEventsUse Case
compact16remDot indicatorsSidebars, cards
default22remDot indicatorsStandard display
large56remLabels with iconsSee Large View below

Large View

Large mode (data-size="large") transforms the calendar into a full-page schedule view with rich event display. Instead of dot indicators, events render as labeled chips with icons and times. Container queries drive responsive cell sizing with near-square proportions.

Event Labels

In large mode, each cell shows up to 2 event chips inline. Events beyond 2 collapse into a "+N more" overflow indicator. Each chip displays the label, optional time, and optional icon.

Day Detail Overlay

In display-only mode (data-selection="none"), clicking a date with events — or pressing Enter / Space on it — opens a positioned, non-modal dialog showing the full event list. If any events have a time property, an hour-grid timeline (<day-view> of <calendar-event>s) renders instead. Focus moves to the dialog's close button when it opens. Escape (while focus is inside the calendar) or the close button closes it and returns focus to the day; clicking outside closes it without moving focus.

Watermark Day Numbers

Large cells display a subtle background day number (watermark) via ::before. Control its appearance with these tokens:

TokenDefaultPurpose
--cal-watermark-opacity0.05Background number opacity
--cal-watermark-colorvar(--color-text)Background number color
--cal-watermark-size3remBackground number font size
--cal-watermark-weight800Background number font weight

Multi-day Events

Add end (inclusive ISO date) or days (a count of 1 or more) to an event object to make it span several days. end wins if both are present. In data-size="large" spans render as continuous bars across each week row; in compact and default sizes they add a dot to every day they cover, and every covered day opens the span in the day detail.

Event Dots

Pass event data as JSON to show dot indicators on dates. Each date can have a string, object with label/color/icon/time, or array of those.

Localization

The locale is the nearest lang attribute (on the element or an ancestor), falling back to the browser language. It drives weekday headers, month names, grid labels, the day-detail title, time labels, and the first day of the week (from Intl.Locale week info).

The few built-in UI strings (button names, the "+N more" overflow) default to English; translate them with the data-label-* attributes.

Keyboard

KeyAction
Arrow Left / Arrow RightMove focus one day (mirrored in right-to-left layouts). Disabled days are skipped; the view follows into adjacent months.
Arrow Up / Arrow DownMove focus one week.
Home / EndMove focus to the first or last day of the week row within the month.
Page Up / Page DownMove focus to the same day in the previous or next month. The day is clamped to the length of the month.
Shift + Page Up / Page DownMove focus to the same day in the previous or next year.
Enter / SpaceSelect the focused date, or in display mode open its day detail.
EscapeClose the day detail and return focus to the day.

Calendar vs Date Picker

ComponentPurposeForm input?
<date-picker> Pick a single date via popover input Yes (ElementInternals)
<calendar-wc> Display events, availability, ranges, multi-select Yes (when name attribute is set)

Theming

The calendar exposes 27 CSS custom properties for expressive theming — from paper wall calendars to bold geometric styles. Every token defaults to transparent or the base appearance, so they are fully opt-in. Themes set them via [data-theme~="name"] calendar-wc { ... } selectors.

Banner

TokenDefaultPurpose
--cal-banner-height0pxBanner strip height (0 hides it)
--cal-banner-bgtransparentBackground color or gradient
--cal-banner-imagenoneBackground image
--cal-banner-sizecoverBackground-size
--cal-banner-positioncenterBackground-position

Header and Week Rows

TokenDefaultPurpose
--cal-header-bgvar(--color-surface-raised)Navigation header background
--cal-header-colorinheritNavigation header text
--cal-week-bgtransparentWeek row background
--cal-week-bg-alttransparentAlternating even-row tint

Day Cells

TokenDefaultPurpose
--cal-day-bgtransparentDay cell background
--cal-day-imagenoneDecoration layer image (stickers)
--cal-day-image-sizecontainDecoration background-size
--cal-day-image-opacity1Decoration opacity

Today, Disabled, Outside

TokenDefaultPurpose
--cal-today-bgvar(--color-surface-raised)Today cell background
--cal-today-bordervar(--color-border-strong)Today cell border
--cal-today-shadownoneToday cell glow or shadow
--cal-disabled-opacity0.5Disabled day opacity
--cal-outside-opacity0.35Outside-month day opacity
--cal-outside-colorvar(--color-text-muted)Outside-month text color

Highlight

TokenDefaultPurpose
--cal-highlight-bginteractive tintHighlighted date background
--cal-highlight-borderinteractive tintHighlighted date border

Accessibility

  • Each month is a <table role="grid"> labelled with its localized month and year; each day is a <button> inside the gridcell.
  • Exactly one day button across all visible months is in the tab order (roving tabindex): the last focused day, else the selection, else today, else the first enabled day.
  • Today carries aria-current="date"; disabled days are disabled buttons with aria-disabled="true".
  • In selection modes, aria-selected is set on the gridcell (<td>) — true for selected or in-range days, false otherwise — and multi/range grids carry aria-multiselectable="true". Display-only grids have no selection state.
  • The month header uses aria-live="polite" for navigation announcements.
  • The day detail is a non-modal role="dialog" named by its date heading; focus moves in on open and back to the day on close.

Related

↑