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.
Availability is when the calendar, or a person or a room, can be booked: business hours are open, and the evenings, the weekend and a holiday are closed. The week and day shade the closed time, the month mutes closed days, and a policy decides what happens to a change that lands outside the hours: the change can be blocked, or saved with a warning.
The registry's month mutes the closed days: here the weekends, and Friday the 16th, a company day. Drag an event onto one and the strip under the calendar, which shows what a screen reader announces, says the change is outside working hours.
import { availabilityPolicy, type CalendarAvailability } from "@moltenship/calendar-solid";
import { createSignal } from "solid-js";
import { applyChange, seed } from "./month-events";
import { Calendar, type Event } from "./month-page";
import { Spoken } from "./spoken";
const time = (value: string) => Temporal.PlainTime.from(value);
const openingHours: CalendarAvailability = {
weekly: [{ days: [1, 2, 3, 4, 5], start: time("09:00"), end: time("17:00") }],
exceptions: [{ date: Temporal.PlainDate.from("2026-10-16"), label: "Company day" }],
};
// "warn" saves a change outside the hours and says so; "block" refuses it.
const policies = [availabilityPolicy<Event, string, string>({ mode: "warn" })];
export default function OpeningHoursPage() {
const [events, setEvents] = createSignal(seed);
return (
<Calendar.Root
availability={openingHours}
defaultAnchorDate={Temporal.PlainDate.from("2026-10-08")}
defaultTimeZone="UTC"
defaultView="month"
events={events()}
locale="en-US"
onEventChange={(change) => {
setEvents((current) => applyChange(current, change));
}}
policies={policies}
weekRules={{ firstDay: 7, minimalDays: 1, weekend: [6, 7] }}
>
<Calendar.Frame class="flex h-dvh flex-col">
<Calendar.Viewport class="min-h-0 flex-1">
<Calendar.ActiveView />
</Calendar.Viewport>
<Spoken />
</Calendar.Frame>
</Calendar.Root>
);
}Add working hours
Pass the calendar's hours to Root as availability, and add availabilityPolicy to its policies:
import { availabilityPolicy, type CalendarAvailability } from "@moltenship/calendar-solid";
import { weekRules } from "./app";
import { Schedule, type Appointment } from "./schedule";
import { resources } from "./schedule-resources";
const time = (value: string) => Temporal.PlainTime.from(value);
const officeHours: CalendarAvailability = {
weekly: [{ days: [1, 2, 3, 4, 5], start: time("09:00"), end: time("17:00") }],
exceptions: [
{ date: Temporal.PlainDate.from("2026-12-25"), label: "Christmas" },
{
date: Temporal.PlainDate.from("2026-12-24"),
hours: [{ start: time("09:00"), end: time("12:00") }],
},
],
};
const policies = [availabilityPolicy<Appointment, string, string>({ mode: "warn" })];
export function Office(props: { appointments: readonly Appointment[] }) {
return (
<Schedule.Root
label="Office"
events={props.appointments}
resources={resources}
availability={officeHours}
policies={policies}
defaultAnchorDate={Temporal.PlainDate.from("2026-12-21")}
defaultTimeZone="Europe/Berlin"
locale="en-US"
weekRules={weekRules}
>
<Schedule.ActiveView />
</Schedule.Root>
);
}Schedule is a calendar whose events book people and rooms; your own idea of busy
shows it. Without availabilityPolicy, views still shade the hours, but nothing stops a change
outside them.
Hours and exceptions
- Weekly hours. Each rule opens
starttoendon itsdays, ISO days of the week from1(Monday) to7(Sunday). A day can have several rules, such as a lunch break between two. Anendat or beforestartruns past midnight, so22:00to06:00is a night and00:00to00:00a whole day. Leaveweeklyout to open every day all day. - Exceptions. An exception replaces one date's hours. Without
hoursit closes the date; itslabel, such as "Christmas", names the closed day in the month and year views. - Time zones. The hours are on the display time zone's clock unless
availability.timeZonesays otherwise, such as the office's. - Daylight saving time. Hours are half-open,
[start, end), and read on the wall clock. On a spring-forward day, hours that start in the skipped hour open when the clock jumps. On a fall-back day, hours that end in the repeated hour close after the repeat, so they cover both.
Invalid rules, exceptions and time zones are left out and reported through onDiagnosticsChange
as invalid-availability. The calendar never throws over them.
People and rooms
Resources follow the calendar's hours unless they have their own:
import type { AvailabilityRule, CalendarResource } from "@moltenship/calendar-solid";
import type { Member } from "./schedule";
const weekdays = (start: string, end: string): AvailabilityRule => ({
days: [1, 2, 3, 4, 5],
start: Temporal.PlainTime.from(start),
end: Temporal.PlainTime.from(end),
});
const room: Member = { kind: "room" };
const person: Member = { kind: "person" };
export const resources: readonly CalendarResource<Member>[] = [
{
id: "orchid",
title: "Orchid",
data: room,
availability: { weekly: [weekdays("08:00", "20:00")] },
},
{ id: "alex", title: "Alex", data: person, timeZone: "America/Los_Angeles" },
{ id: "lee", title: "Lee", data: person, timeZone: "Asia/Kolkata" },
];-
Own hours. A resource's
weeklyreplaces the calendar's. Itsexceptionsadd to the calendar's, so a company holiday closes every room, and the resource's own win on the same date. -
Own time zone. A resource with a
timeZonekeeps its hours on that clock: Alex's 9 to 5 in Los Angeles shows as the evening in Berlin. -
The same instant. Moving an event to a resource in another time zone keeps its instant: a 9:00 call in New York stays 9:00 in New York, which is 14:00 for London.
-
One time axis. Resource columns and the timeline keep a single axis in the display time zone. Only the shading follows each resource's clock, and its header shows its local time and UTC offset, such as "7:18 AM GMT-7", while that clock differs from the display time zone's.
Customize the shading
Each stretch of closed time is a div hidden from screen readers. It carries why it is closed and
where it meets open time, so CSS can restyle it:
| Attribute or variable | Value |
|---|---|
data-slot | time-grid-unavailable in the week and day, resource-timeline-unavailable in the timeline, month-closed in the month, or year-closed in the year |
data-reason | outside-hours, closed-day (no weekly hours that day) or exception (a closed date) |
data-label | The exception's label, such as "Company holiday" |
data-opens-before, data-opens-after | Present where open time meets the band's start or end in the view |
--band-start, --band-end | Where the band starts and ends along its column or row, as percentages |
// The recipes in `shading-recipes.css` apply under the frame's `data-recipe`.
export default function ShadingRecipesPage() {
const now = Temporal.Now.zonedDateTimeISO();
const [events, setEvents] = createSignal(thisWeek(now.toPlainDate(), now.timeZoneId));
const [recipe, setRecipe] = createSignal<string>("gradient");
return (
<Calendar.Root
availability={officeHours(now.toPlainDate())}
defaultAnchorDate={now.toPlainDate()}
defaultTimeZone={now.timeZoneId}
defaultView="week"
events={events()}
locale="en-US"
onEventChange={(change) => {
if (change.cause === "create" || change.cause === "delete") return;
setEvents((all) =>
all.map((event) =>
event.id === change.eventId ? { ...event, ...change.proposed } : event,
),
);
}}
weekRules={{ firstDay: 1, minimalDays: 4, weekend: [6, 7] }}
>
<Calendar.Frame class="flex h-dvh flex-col" data-recipe={recipe()}>
<div class="flex h-14 shrink-0 items-center border-b px-4">
<SegmentedControl
aria-label="Recipe"
class="relative isolate flex gap-1 rounded-full bg-muted p-1"
onValueChange={(next) => {
if (next !== null && next !== undefined) setRecipe(String(next));
}}
value={recipe()}
>
<SegmentedControlIndicator class="absolute top-(--segmented-control-indicator-top) left-(--segmented-control-indicator-left) -z-10 h-(--segmented-control-indicator-height) w-(--segmented-control-indicator-width) rounded-full bg-background shadow-sm transition-all duration-200 data-[activation-direction=none]:transition-none" />
<For each={recipes}>
{(item) => (
<SegmentedControlItem
class="relative rounded-full px-3 py-1 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring data-checked:font-medium"
value={item.value}
>
{item.label}
</SegmentedControlItem>
)}
</For>
</SegmentedControl>
</div>
<Calendar.Viewport class="min-h-0 flex-1">
<Calendar.ActiveView />
</Calendar.Viewport>
</Calendar.Frame>
</Calendar.Root>
);
}/* Gradient: closed time fades out over the last hour and a half before working hours. */
[data-slot="time-grid-unavailable"] {
--calendar-unavailable: color-mix(in oklch, var(--muted-foreground) 16%, transparent);
/* Never more than half the band, so a short closure between open hours still shows. */
--fade: min(calc(var(--calendar-hour-height) * 1.5), 50%);
}
[data-slot="time-grid-unavailable"][data-opens-after] {
mask-image: linear-gradient(to bottom, black calc(100% - var(--fade)), transparent);
}
[data-slot="time-grid-unavailable"][data-opens-before] {
mask-image: linear-gradient(to top, black calc(100% - var(--fade)), transparent);
}
[data-slot="time-grid-unavailable"][data-opens-before][data-opens-after] {
mask-image: linear-gradient(
transparent,
black var(--fade),
black calc(100% - var(--fade)),
transparent
);
}
/* Hatching, with holidays tinted. */
[data-slot="time-grid-unavailable"] {
background: repeating-linear-gradient(
-45deg,
transparent 0 6px,
color-mix(in oklch, var(--muted-foreground) 25%, transparent) 6px 7px
);
}
[data-slot="time-grid-unavailable"][data-reason="exception"] {
background-color: color-mix(in oklch, var(--brand) 8%, transparent);
}
/* A brand tint, through the token every view reads. */
:root {
--calendar-unavailable: color-mix(in oklch, var(--brand) 12%, transparent);
}The default tint is --calendar-unavailable for closed time and --calendar-closed for closed
days in the month. In the dark theme closed time is lighter than open time, since a near-black
surface has little room to get darker. Recipes built on --muted-foreground or your own tokens
follow the theme the same way.
To draw something else, pass renderUnavailable to a view: a function of the band's props and its
state that returns an element. The state holds the band (its reason, label and edges), the
column's date and the resource whose hours it shows, or null for the calendar's own. Keep the
props on your element: they place it and keep it hidden from screen readers.
import { Show } from "solid-js";
import { createMonthView } from "@/components/calendar/month-view/month-view";
import { createWeekView } from "@/components/calendar/time-grid-view/time-grid-view";
import type { UnavailableTimeRender } from "@/components/calendar/unavailable-time";
import type { Event } from "./week-page";
// A closed date names itself inside its band, such as "Christmas".
const labelHolidays: UnavailableTimeRender = (props, state) => (
<div {...props}>
<Show when={state.band.reason === "exception" ? state.band.label : undefined}>
{(label) => <span class="m-1 block text-xs text-muted-foreground">{label()}</span>}
</Show>
</div>
);
export const views = [
createWeekView<Event>({ renderUnavailable: labelHolidays }),
createMonthView<Event>({ renderUnavailable: labelHolidays }),
];The week, day, month, year, resource columns and resource timeline take renderUnavailable, and so
do the scrolling week, day and month. The agendas don't shade closed time.
Busy or available
Working hours and events answer two different questions. Unavailable means outside working hours. Busy means an event occupies the time. A person can be busy outside their hours, at a late call, or free during them. The status API keeps the two apart:
import {
availabilityAt,
busyAt,
type AvailabilitySnapshot,
type EventSnapshot,
} from "@moltenship/calendar-solid";
import type { Appointment } from "./schedule";
// A view gets `events`, the root's event snapshot, in its props. `availability` is what
// `useCalendarAvailability()` returns.
export function statusOfMaya(
availability: AvailabilitySnapshot,
events: EventSnapshot<Appointment, string, string>,
now: Temporal.Instant,
) {
const hours = availabilityAt(availability, now, "maya");
// { available: true, closesAt: Temporal.Instant }
// { available: false, reason: "outside-hours" | "closed-day" | "exception", label?, opensAt }
const busy = busyAt(events, now, { resourceId: "maya", timeZone: "Europe/Berlin" });
// { busy: true, events: [...], freeAt: Temporal.Instant }
// { busy: false, nextEventAt: Temporal.Instant | null }
return { hours, busy };
}- Time zones. Hours are read on the resource's own clock, as the shading is, and are safe across daylight saving changes. All-day and floating events count on the wall clock you pass, usually the display time zone, as the views show them.
- Which events are busy. Timed and floating events are; all-day ones, such as a holiday
banner, aren't, as in Google Calendar. The event adapter's
isBusyoverrides that; see Customize. - Overlaps.
eventslists everything in progress.freeAtis when the last of a run of overlapping or back-to-back events ends, so a 10:00 standup followed by an 11:00 review is busy until the review ends. - Horizons.
opensAtandclosesAtlook up to a year ahead, andfreeAtandnextEventAta month ahead. They arenullpast that.
useResourceStatus(resourceId, at?) returns an accessor of both, plus changesAt, the next
instant either can change. Without at it follows the calendar's clock or now. It updates only
when the status changes, waking at changesAt rather than on every tick. It is null while server
rendering and hydrating, unless the calendar fixes now.
import { useResourceStatus } from "@moltenship/calendar-solid";
import { Show } from "solid-js";
// Render it inside the calendar's root.
export function Presence(props: { id: string }) {
const status = useResourceStatus(() => props.id);
return (
<Show when={status()}>
{(current) => (
<span>
{current().busy.busy
? "In a meeting"
: current().availability.available
? "Around"
: "Away"}
</span>
)}
</Show>
);
}Busy badge in resource views
Set resourceStatus: true on the resource columns or the
timeline to show a badge on each resource, as the timeline in
People and rooms does:
const Calendar = createCalendar<Meeting, Member>()({
eventAdapter: createCanonicalEventAdapter<{ readonly color: CalendarEventColor }>(),
views: [
createTimelineDayView<Meeting, Member>({
getEventColor: (meeting) => meeting.data.color,
resourceStatus: true,
}),
],
});| State | Shows |
|---|---|
| Busy | "Busy until 3:00 PM", while events occupy it |
| Free | "Free until 5:00 PM", until its next event or closing time |
| Outside hours | "Outside hours until Mon 9:00 AM", until it opens |
| Closed today | "Closed today", or "Closed today, Company holiday" |
The words carry the state; the dot before them is colored with --calendar-busy or
--calendar-free. Times are on the display clock, with the weekday within the next six days and the date further out. Busy
wins over the hours, so a late call shows as busy. The badge is the calendar's Badge.
A group shows no badge, since its own bookings aren't its members'. For a badge anywhere else,
useResourceStatusSummary(environment, resourceId) from resource-status.tsx returns an accessor
of the words and state, and ResourceStatusBadge draws them. Both arguments are accessors:
environment of the locale and timeZone a view gets in its props, and resourceId of a
resource's ID, or null for no badge.
Scheduling: who's busy?
While you place an event, by dragging or with the keyboard, each resource's header says whether
it's busy then: Busy when an event overlaps the draft, Outside hours when the time is
outside its hours, Free otherwise. The resource columns and the timeline show it with
resourceStatus on: move an event in the timeline in People and rooms, and
watch the row headers. The draft's own event never conflicts with itself, and events that only
touch don't conflict.
It all rests on one function. busyResources answers for many resources at once, with one query
of the event index, bucketed by each event's resources, so a busy person never marks the others:
import {
busyResources,
type EventSnapshot,
type InstantInterval,
} from "@moltenship/calendar-solid";
import type { Appointment } from "./schedule";
export function whoIsBusy(
events: EventSnapshot<Appointment, string, string>,
range: InstantInterval,
) {
const busy = busyResources(events, range, {
exclude: "evt_42", // the event being moved, if any
resourceIds: ["orchid", "lotus", "maya"], // or leave out for every resource
timeZone: "Europe/Berlin", // for all-day and floating events
});
busy.get("maya"); // [standup, review]: the events that make Maya busy then
busy.has("lotus"); // false: free resources are absent
return busy;
}The range can also be a placement, all-day or floating, read on timeZone. The hooks return accessors:
| Hook | Returns |
|---|---|
useBusyResources(range, opts?) | busyResources over the root's events, once per change of events or range |
useCalendarDraft() | The change being placed, by pointer or keyboard: { eventId, proposed }, or null |
useDraftBusy(resourceId) | A resource during the draft: { events, outsideHours }, or null without one |
Drafts step by slots, so these change at most once a step. useDraftBusy works the draft's busy
resources out once for every component that asks, and each one updates only when its own resource's
answer changes.
An all-day draft shows who has busy time that day, even though an all-day event is free by default
and so doesn't conflict under conflictPolicy; the status is information, not a rule. To flag or
prevent double-booking on save, see double booking.
Customize
Your own idea of busy. The event adapter's isBusy is the one place that decides, for the
status, the draft headers, busyResources and conflictPolicy alike:
import {
createCalendar,
defineEventAdapter,
type CalendarEventInterval,
type CalendarResource,
} from "@moltenship/calendar-solid";
export interface Appointment {
readonly id: string;
readonly title: string;
readonly interval: CalendarEventInterval;
readonly attendeeIds: readonly string[];
readonly calendarId: string;
readonly showAs?: "busy" | "tentative";
}
export interface Member {
readonly kind: "person" | "room";
}
const eventAdapter = defineEventAdapter<Appointment>()({
getId: (appointment) => appointment.id,
getTitle: (appointment) => appointment.title,
getInterval: (appointment) => appointment.interval,
getResourceIds: (appointment) => appointment.attendeeIds,
// Focus time and tentative meetings leave you bookable; all-day ones block when marked busy.
isBusy: (appointment) =>
appointment.title !== "Focus time" &&
appointment.showAs !== "tentative" &&
(appointment.interval.kind !== "all-day" || appointment.showAs === "busy"),
});
export const Schedule = createCalendar<Appointment, CalendarResource<Member>>()({ eventAdapter });Your own "who's busy" UI. Any component inside the root can ask. This picker lists each room with what keeps it busy during an interval. Busy rooms stay in the list, since a double booking can be on purpose:
import { useBusyResources, type CalendarEventInterval } from "@moltenship/calendar-solid";
import { For } from "solid-js";
import { resources } from "./schedule-resources";
const rooms = resources.filter((resource) => resource.data.kind === "room");
export function RoomPicker(props: { interval: CalendarEventInterval; eventId?: string }) {
// Accessors, so the answer follows the props.
const busy = useBusyResources(
() => props.interval,
() => ({ exclude: props.eventId }),
);
const bookings = (roomId: string) => busy().get(roomId) ?? [];
return (
<ul>
<For each={rooms}>
{(room) => (
<li data-busy={bookings(room.id).length > 0 ? "" : undefined}>
{room.title}
{bookings(room.id).length > 0
? `, busy: ${bookings(room.id)
.map((event) => event.title)
.join(", ")}`
: ", available"}
</li>
)}
</For>
</ul>
);
}Double booking
conflictPolicy in the root's policies checks a change against double-booking: a busy event
may not overlap another busy event of a resource it books. It runs the same query as
busyResources, with the reason "resource-conflict". Each resource can follow its own mode, so a
room can't be double-booked while a person can, with a warning.
The timeline in People and rooms has these policies: drag a meeting onto Orchid's interview, and the room blocks it, or onto one of Alex's or Lee's, and it saves, flagged.
import { conflictPolicy, type CalendarPolicy } from "@moltenship/calendar-solid";
import type { Appointment } from "./schedule";
import { resources } from "./schedule-resources";
const rooms = new Set(
resources.filter((resource) => resource.data.kind === "room").map((resource) => resource.id),
);
// <Schedule.Root policies={policies} resources={resources} … />
export const policies = [
conflictPolicy<Appointment, string, string>({
mode: "warn", // people, and any resource getResourceMode leaves out
getResourceMode: (resourceId) => (rooms.has(resourceId) ? "block" : undefined),
}),
];| Mode | Double-booking the resource… |
|---|---|
"block" | Rejects the change, and the event goes back where it was. The default. |
"warn" | Saves it, with "resource-conflict" in its warnings, so you can say so or ask first. |
"allow" | Saves it as it is, as if the resource had no check. |
modeis the mode for every resource.getResourceModegives a resource its own, by its ID;undefinedkeepsmode. Policies don't see your resources, so look the ID up in yours, as above.- When a change double-books several resources, the strictest of their modes decides: any
"block"rejects it, and otherwise any"warn"flags it. A room that's free doesn't block a meeting whose person is busy. - Only what a change alters is checked: its time, or the resources it adds when the time stays.
An event that's already double-booked can still be edited. Resources in
"allow"mode aren't queried at all, and deletes always pass. - Events that only touch don't conflict, and an event that isn't busy books nothing: the event
adapter's
isBusydecides, forconflictPolicyas for the status. - The modes decide what saving does, not who's busy. A person in
"allow"mode still shows as busy touseResourceStatusanduseDraftBusy.
There's no mode per calendar. A conflict is between two bookings of one resource, often from
different calendars, and a new event has no calendar yet when the policies run. To keep a whole
calendar out of conflicts, such as tentative holds, mark its events free in isBusy. For stricter
checks on one calendar's events, choose between two policies in your own, since a policy is a
function:
const strict = conflictPolicy<Appointment, string, string>({ mode: "block" });
const lenient = conflictPolicy<Appointment, string, string>({ mode: "warn" });
export const byCalendar: CalendarPolicy<Appointment, string, string> = (change, context) =>
change.event?.calendarId === "interviews" ? strict(change, context) : lenient(change, context);Keep changes inside
availabilityPolicy({ mode }) checks every move, resize and create, whether it comes from a drag,
the keyboard, or actions.proposeEventChange. An event with resources must fit the hours of each
resource it books, on that resource's clock: its own hours, or the calendar's when it has none. So a
room open until 20:00 takes an 18:00 booking even when the office closes at 17:00. An event without
resources must fit the calendar's hours. A timed event must fall in open time, and an all-day event
on dates with open time. Only what a change alters is checked, so events already outside the hours
can still be edited.
| Mode | Outside the hours, the change is… |
|---|---|
"block" | Rejected with the reason "outside-availability", and the event goes back where it was. |
"warn" | Saved, with "outside-availability" in its warnings, so you can say so or ask to confirm. |
Your own UI can ask what the policies would say with actions.checkEventChange(proposal), which
runs them without saving anything.
Your own view
The shading is separate from the event projection, like annotations, so working hours never change event layout. These hooks give a view what to draw, for the calendar's hours or, with a resource ID, that resource's:
| Hook | Returns |
|---|---|
useTimeGridAvailability(columns, id?) | The closed bands of each time-grid column, as fractions of 24 h |
useTimelineAvailability(columns, id?) | The closed stretches along a timeline, as fractions of its width |
useClosedDates(range, id?) | The dates with no open time, keyed by ISO date, with a reason and label |
useResourceStatus(id?, at?) | Working hours and events at an instant, and when either changes |
useCalendarAvailability() | The resolved hours: calendar, forResource(id), timeZone |
Bands and stretches carry their reason, label, opensBefore and opensAfter, as the
attributes above do.
The hooks return accessors. This week view shades each day's closed time:
import {
defineCalendarView,
timeGridStrategy,
useTimeGridAvailability,
} from "@moltenship/calendar-solid";
import { For } from "solid-js";
export const weekView = defineCalendarView({
name: "week",
strategy: timeGridStrategy({ kind: "week" }),
Renderer: (props) => {
// One list of closed bands per column, as fractions of the column's 24 hours.
const closed = useTimeGridAvailability(() => props.projection.days.map((day) => day.column));
return (
<div class="week">
<For each={props.projection.days}>
{(day, index) => (
<div class="week-day" data-date={day.column.date.toString()}>
<For each={closed()[index()]}>
{(band) => (
<div
class="closed"
aria-hidden="true"
data-reason={band.reason}
data-label={band.label}
style={{ top: `${band.top * 100}%`, height: `${band.height * 100}%` }}
/>
)}
</For>
{/* The day's events */}
</div>
)}
</For>
</div>
);
},
});.closed {
position: absolute;
inset-inline: 0;
background: color-mix(in oklch, currentColor 8%, transparent);
}
.closed[data-reason="exception"] {
background: color-mix(in oklch, currentColor 14%, transparent);
}The bands are hidden from screen readers, so give the same information in words, such as "outside working hours" in a slot's label.
Each schedule answers available(range), unavailable(range) and isAvailable(range) for any
instant range, and resolves each date once, so views can ask as often as they like.
Data model
Prop
Type
A resource's availability takes weekly and exceptions, and its timeZone sits on the
resource itself.