Annotations
Time-based information beside events, such as listening history, sleep, workouts and focus sessions.
Annotations show what happened alongside the events: what you listened to, when you slept, a workout, a focus session. Unlike events they are read-only, and they never take part in overlap layout, so they never reorder an event or change its lane.
The calendar doesn't fetch anything. Your app loads the data from its integrations and passes it to
Root, the same way it passes events.
Add them
Describe each source once, then turn your data into annotations:
import {
createCalendar,
defineCalendarView,
summarizeAnnotationMarks,
timeGridStrategy,
useTimeGridAnnotations,
type CalendarAnnotation,
type CalendarAnnotationSource,
} from "@moltenship/calendar-solid";
import { For } from "solid-js";
import { seed, weekRules } from "./app";
import { eventAdapter, type Meeting } from "./calendar";
interface Play {
readonly id: string;
readonly track: string;
readonly artist: string;
readonly startedAt: string;
readonly endedAt: string;
}
export const sources: readonly CalendarAnnotationSource[] = [
{ id: "sleep", label: "Sleep" },
// Tracks less than five minutes apart draw as one listening session.
{ id: "music", label: "Music", mergeGap: Temporal.Duration.from({ minutes: 5 }) },
];
export function listeningHistory(plays: readonly Play[]): CalendarAnnotation[] {
return plays.map((play) => ({
id: play.id,
sourceId: "music",
start: Temporal.Instant.from(play.startedAt),
end: Temporal.Instant.from(play.endedAt),
title: `${play.track} · ${play.artist}`,
}));
}Pass both to Root. Tracker here is a calendar with the week view that
Draw them in your own view writes. With the registry's week, pass
them the same way and the week and day draw them:
export function Week(props: { plays: readonly Play[] }) {
return (
<Tracker.Root
label="Team calendar"
events={seed}
defaultAnchorDate={Temporal.PlainDate.from("2026-10-08")}
defaultTimeZone="Europe/Berlin"
locale="en-US"
weekRules={weekRules}
annotationSources={sources}
annotations={listeningHistory(props.plays)}
>
<Tracker.ActiveView />
</Tracker.Root>
);
}The library knows no kinds of source: "sleep" and "music" are your names. Sources come in the order
you list them, and leaving one out of annotationSources hides its annotations. Like events,
annotations are half-open, [start, end). Invalid ones are skipped and reported through
onDiagnosticsChange.
The week and day
The registry's week and day views draw annotations as soon as Root has sources. Without any,
they draw no rail. Give each source a color from the event palette and an Icon:
function MoonIcon(props: { readonly class?: string }) {
return (
<svg class={props.class} viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z" />
</svg>
);
}
function MusicIcon(props: { readonly class?: string }) {
return (
<svg class={props.class} viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M9 18V5l12-2v13" />
<circle cx="6" cy="18" r="3" />
<circle cx="18" cy="16" r="3" />
</svg>
);
}
const sources: readonly TimeGridAnnotationSource[] = [
{ id: "sleep", label: "Sleep", color: "purple", Icon: MoonIcon },
{
id: "music",
label: "Music",
color: "green",
Icon: MusicIcon,
// Tracks less than five minutes apart draw as one listening session.
mergeGap: Temporal.Duration.from({ minutes: 5 }),
},
];- A rail beside the events. The marks draw in a narrow strip at the start of each day column,
18px in the week and 30px in the day. An event moves aside for the rail only where a mark is
beside it, counting a short mark as tall as the rail's
markWidth. The events it shares lanes with move with it, so they keep their places beside each other. Every other event, and every event on a day without marks, keeps the column's whole width. Withplacement: "overlay"the parts draw behind events instead and move nothing. - Capsules with the source's icon. Each annotation draws as a capsule in its source's color, with the icon inside its top. A mark is never shorter than it is wide, so a short session is a circle with the icon.
- Merging. A source's annotations closer than its
mergeGapdraw as one mark, such as tracks into a listening session. Marks whose circles would touch merge too, so song-level history stays readable when zoomed out. - Lanes. When different sources overlap, such as music during a focus session, they share the rail in up to three narrower lanes. Too narrow for an icon, a mark drops it.
- Days. An annotation across midnight shows on both days. A part that starts the day before fades in at the top and has no icon.
- Details. Hovering a mark shows a tooltip, and clicking it opens a popover listing what it
merges. Both are the kit's, in
components/calendar/ui/, one of each for the whole grid. The popover keeps focus until Escape or its close button, which return focus to where it was, or an outside click, which leaves focus where the click put it. Pressing or dragging a mark never starts a new event.
Customize them
The rail is registry source like the rest of the view, built from small parts you can restyle, recompose or edit. From the lightest change to the heaviest:
CSS. Each mark has data-slot="annotation-mark", data-source, data-color, data-kind
(bar or dot), and data-starts-before or data-ends-after when it's cut at midnight. This
gives sleep a night sky:
[data-slot="annotation-mark"][data-source="sleep"] {
background: linear-gradient(to bottom, oklch(0.5 0.19 282), oklch(0.7 0.14 275));
}Your own composition. Pass a component as the view's annotations.Annotations. It gets one
column's marks, already merged and placed in lanes, and composes the parts:
import { For, Show } from "solid-js";
import {
AnnotationMark,
AnnotationMarkIcon,
AnnotationRail,
type TimeGridAnnotationMarkData,
type TimeGridAnnotationsProps,
} from "@/components/calendar/time-grid-view/time-grid-annotations";
import { createWeekView } from "@/components/calendar/time-grid-view/time-grid-view";
import type { Event } from "./week-page";
/** Your brand's mark, in place of the source's icon. */
function BrandLogo() {
return (
<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
<circle cx="12" cy="12" r="10" />
</svg>
);
}
function MyAnnotations(props: TimeGridAnnotationsProps) {
return (
<AnnotationRail>
<For each={props.marks} keyed={(mark: TimeGridAnnotationMarkData) => mark.key}>
{(mark) => (
<AnnotationMark mark={mark()} class="data-[source=music]:bg-[#1DB954]">
<Show when={mark().source.id === "music"} fallback={<AnnotationMarkIcon />}>
<AnnotationMarkIcon>
<BrandLogo />
</AnnotationMarkIcon>
</Show>
</AnnotationMark>
)}
</For>
</AnnotationRail>
);
}
export const weekView = createWeekView<Event>({ annotations: { Annotations: MyAnnotations } });AnnotationMarkhas the variantscapsule(default),bar(a thin bar that keeps its true length) andband(a tint across the column behind events, withplacement: "overlay"). Itsrenderprop takes a function of the mark's props that returns your element in its place, such as a link to the track. Spread the props last, so they place it and wire its tooltip and popover. Put your own handlers and attributes on theAnnotationMarkitself: it passes them on and runs your handlers before its own.AnnotationMarkIcondraws the source'sIcon. Children replace it.useAnnotationMark()gives any part inside a mark its mark and width.
Rail size and lanes. These are numbers rather than CSS, because merging and lane packing use them:
// Thin bars that keep their true length.
export const barsView = createWeekView<Event>({
annotations: { rail: { width: 10, markWidth: 4 } },
});The parts themselves. time-grid-annotations.tsx is yours: change the capsule, the tooltip or
the popover there.
Anatomy
TimeGridColumn time-grid-column.tsx
└── TimeGridAnnotations time-grid-annotations.tsx, or yours
└── AnnotationRail data-slot="annotation-rail", aria-hidden
└── AnnotationMark data-slot="annotation-mark", one per mark
└── AnnotationMarkIcon data-slot="annotation-mark-icon"Options
Prop
Type
Set them as the week or day view's annotations option.
Keyboard and screen readers
Annotations add no keys and no tab stops: the grid keeps its single tab stop and its
key map. The rail is aria-hidden, and screen readers get the
same information in words instead:
| Where | What a screen reader hears |
|---|---|
| A day's header | A summary of its annotations: "Annotations: Sleep until 7:05 AM. Music, 3 times, 2 hours, 10 minutes." |
| A slot, with ↑ ↓ | The items drawn across it, after its time: "Music: Nightcall, 9:00 AM to 9:04 AM; Genesis, 9:05 AM to 9:09 AM" |
Hover effects respect prefers-reduced-motion.
Draw them in your own view
useTimeGridAnnotations(columns, geometry) lays the annotations out beside a time grid's columns
and returns an accessor of one list of marks per column. This week view draws them in a rail at the
start of each day:
export const weekView = defineCalendarView({
name: "week",
strategy: timeGridStrategy({ kind: "week" }),
Renderer: (props) => {
// One list of marks per column. A mark is never shorter than 2% of the day, about half an hour.
const marks = useTimeGridAnnotations(() => props.projection.days.map((day) => day.column), {
minHeight: 0.02,
});
return (
<div class="week">
<For each={props.projection.days}>
{(day, index) => (
<div class="week-day" data-date={day.column.date.toString()}>
<div class="rail" aria-hidden="true">
<For each={marks()[index()]}>
{(mark) => (
<span
class="mark"
data-source={mark.source.id}
data-kind={mark.kind}
title={mark.annotations.map((annotation) => annotation.title).join(", ")}
style={{
top: `${mark.top * 100}%`,
height: `${mark.height * 100}%`,
left: `${(mark.lane / mark.lanes) * 100}%`,
width: `${100 / mark.lanes}%`,
}}
/>
)}
</For>
</div>
{/* The day's events */}
</div>
)}
</For>
</div>
);
},
});Register the view, and the Root above renders it:
export const Tracker = createCalendar<Meeting>()({ eventAdapter, views: [weekView] });A mark is one source's annotations merged and placed, ready to draw:
- Position.
topandheightare fractions of the column's 24-hour axis, like an event's layout.kindis"dot"for a mark shorter than the geometry'sminHeight, which draws at that height, and"bar"for the rest. - Merging. A source's annotations closer than its
mergeGapare one mark, such as tracks in a listening session. Marks closer than the geometry'sminGapmerge too, so song-level history stays readable when zoomed out.mark.annotationslists what a mark merges, in time order. - Lanes. When different sources overlap, such as music during a focus session, they share the
rail:
laneis the mark's lane andlaneshow many it shares the rail with. - Days. An annotation across midnight gives a mark on both days.
startsBeforeDayandendsAfterDaysay where a mark is cut, so you can fade that end.
Style the marks with your own CSS. The sample puts the source's ID in data-source:
.rail {
position: absolute;
inset-block: 0;
inset-inline-start: 0;
inline-size: 18px;
}
.mark {
position: absolute;
border-radius: 999px;
background: oklch(0.7 0.15 150);
}
.mark[data-source="sleep"] {
background: linear-gradient(to bottom, oklch(0.5 0.19 282), oklch(0.7 0.14 275));
}The sample's rail is aria-hidden, so say the same in words. summarizeAnnotationMarks returns a
day's totals per source, in source order, for a day's header or a screen-reader summary:
export function DaySummary(props: { marks: Parameters<typeof summarizeAnnotationMarks>[0] }) {
const hours = (duration: Temporal.Duration) =>
duration.round({ largestUnit: "hours", smallestUnit: "minutes" }).toLocaleString("en");
return (
<ul>
<For each={summarizeAnnotationMarks(props.marks)}>
{(summary) => (
<li>
{summary.source.label}: {summary.count} times, {hours(summary.duration)}
</li>
)}
</For>
</ul>
);
}useCalendarAnnotations() returns the root's annotations and sources as they are, for a view that
isn't a time grid.
Geometry
The second argument of useTimeGridAnnotations. Every value is optional.
Prop
Type
Data model
Prop
Type
A source has an id, a label that names it in summaries and tooltips, and an optional
mergeGap. A mark carries the source object you passed, so a source can hold more, such as a
color.
Availability
Working hours, closed days and holidays, people and rooms in their own time zones, shading you can restyle, a busy or free status, and policies that keep bookings inside working hours and rooms from being double-booked.
Accessibility
The keyboard map, screen reader announcements, the ARIA patterns each view uses, reduced motion, and right-to-left layout.