Skip to content

07advanced

API reference

Every export of the copied kloq source — the root module, themes, settings and design-mode — grouped by area.

Every export, grouped by area — the component and its chrome, then the pure layers underneath, then the three companion modules. Types ship alongside the values they describe.

<Kloq> props

proptype · description
view?
"day" | "week" | "workweek" | "month" | "agenda" | "year" | "timeline" | number

Controlled view. Workweek is Monday–Friday; a number is an n-day span (2–14). Pair with onViewChange.

defaultView?
KloqViewdefault "week"

Uncontrolled starting view. Ignored when view is set.

onViewChange?
(view: KloqView) => void

Fired whenever something asks to change the view, controlled or not.

date?
Date

Controlled anchor date. Navigation only reports via onDateChange.

defaultDate?
Date

Uncontrolled starting anchor; defaults to today.

onDateChange?
(date: Date) => void

Fired whenever something asks to move the anchor date.

events?
CalEvent[]

Controlled events. Switches the internal store off — pair with onEventsChange.

onEventsChange?
(events: CalEvent[]) => void

The full next event list on every committed change (controlled mode).

defaultEvents?
CalEvent[]default sample events

Uncontrolled starting events. Omit for the sample events; pass [] to start empty.

lanes?
readonly Lane[]default []

Rows for view="timeline". Ignored by every other view. Empty by default — nothing renders without lanes.

persistence?
false | PersistenceAdapterdefault localStorage

Uncontrolled persistence: false is ephemeral, omit is localStorage, or bring an adapter.

storage?
StorageSettingdefault "kloq"

Everything kloq keeps in localStorage. false keeps it in memory; a string namespaces the keys.

onCommit?
OnCommit

Optimistic seam — called on every committed change; a rejected promise reverts it.

onUndo?
() => void

Controlled-mode undo — ⌘Z calls it.

onRedo?
() => void

Controlled-mode redo — ⇧⌘Z calls it.

onRangeChange?
(start: Date, end: Date) => void

The visible range changed — [start, end). Fires once on mount, then on every view or date change.

rangePadding?
number | { before: number; after: number }default 0

Days to widen the range onRangeChange reports.

density?
"comfortable" | "compact"default "comfortable"

Hour height, event type size and padding together.

zoom?
numberdefault 4

Live zoom as an index into ZOOM_STEPS (0–10; 4 = 100%).

hourHeight?
number

px per hour, clamped to 8–480. Omit and density picks the base.

dayStartHour?
numberdefault 0

First hour the grid draws (0–23); with dayEndHour this clips the day.

dayEndHour?
numberdefault 24

Last hour the grid draws (exclusive).

snapMinutes?
numberdefault 15

Drag and keyboard snap grid.

snapFineMinutes?
numberdefault 5

Snap grid while ⌥ is held.

minEventMinutes?
numberdefault 15

Shortest event a resize can produce.

weekStartsOn?
0 | 1 | 2 | 3 | 4 | 5 | 6default 1

0 = Sunday … 6 = Saturday.

constraints?
KloqConstraints

Bounds (minDate / maxDate), a per-slot refusal and a per-event veto. Refused time draws as a hatch; every gesture honours it.

workingHours?
{ start: number; end: number } | falsedefault { start: 9, end: 17 }

Working-hours tint boundaries; false disables the tint.

showWeekNumbers?
booleandefault false

ISO 8601 week numbers in the gutter corner (time-grid views).

responsive?
ResponsiveSettingdefault true

Collapse a week to three days, then to one, as the box narrows. view is never rewritten.

locale?
stringdefault "en-US"

BCP 47 tag for every date and time label.

hour12?
boolean

Force a 12- or 24-hour clock; omit and the locale decides.

displayTimeZone?
string

Draw the calendar in this IANA zone instead of the browser's.

timeZones?
(string | TimeZoneColumn)[]

Extra gutter zone columns, in order.

designMode?
boolean | { hint?: boolean }default true

Figma-style design mode (⌥D). { hint: false } hides the hint bar.

commandPalette?
boolean | { commands?: string[] }default true

⌘K. false removes the binding and the menu; { commands } narrows the built-ins — spread BUILT_IN_COMMANDS and filter.

globalShortcuts?
booleandefault false

Let ⌘K / ⌘Z / ⌥D fire when focus is outside the calendar.

navigationKeys?
"range" | "day"default "range"

What ←/→ move by. PageUp / PageDown always step the range.

currentUserEmail?
string

Who "you" are. Enables RSVP, per-person conflicts and showDeclinedEvents.

showDeclinedEvents?
booleandefault true

Draw events you have declined.

keymap?
Keymap

Overrides for the remappable mnemonics.

theme?
string

Scope a theme to this calendar and its portals — no <html> attribute, no localStorage. Omit to follow the page (setTheme). See Theming.

scheme?
"light" | "dark"

Pin this calendar's colour scheme regardless of the page's .dark. Omit to follow the page.

components?
Partial<KloqComponents>

Slot overrides — swap any visual piece; the engine keeps the physics.

makeId?
() => stringdefault random UUID

Id factory for everything the calendar creates.

ssr?
booleandefault false

Render the event layer on the server too. Only hydration-safe with controlled events, a date and displayTimeZone.

laneAdapter?
LaneAdapterdefault byResourceId()

How an event maps onto a lane, for view="timeline". See Resources & lanes.

timelineWindow?
TimelineWindowConfig

The timeline's visible span and slot size — controlled (pass start and end) or derived from the anchor date. See Resource timeline.

onEventClick?
(event: CalEvent, placementId: string) => void

An event was clicked or opened from the keyboard, not dragged.

onEventDoubleClick?
(event: CalEvent, placementId: string) => void

Double-click on an event; fires after onEventClick.

onSlotClick?
(slot: { start: Date; end: Date; allDay: boolean }) => void

An empty slot was clicked, snapped like drag-create.

onSelectionChange?
(events: CalEvent[]) => void

The selection changed, in reading order.

onTimeZonesClick?
() => void

The gutter-corner zone labels were pressed; providing it renders them as a button.

onCustomizeKeybinds?
() => void

"Customize shortcuts…" was pressed in the ? sheet.

Component & chrome

ExportKindNotes
KloqcomponentThe calendar. Also carries Kloq.Toolbar / Kloq.Nav / Kloq.Reset. Props: KloqProps.
KloqToolbar / KloqNav / KloqResetcomponentsThe chrome parts as named exports — identical to the dotted forms, and the ones to use from a server component (dotted access doesn't cross the client boundary).
useKloq()hookLive view state (view, date, range, navigation) inside <Kloq> children.
KloqProps / KloqChrome / KloqToolbarPropstypesThe prop surfaces above.

Configuration

ExportKindNotes
createSettings / DEFAULT_CONFIG / DEFAULT_SETTINGSfunction + constantsResolve a KloqConfig (props) into a validated KloqSettings (geometry + formatting).
useKloqSettings()hookThe resolved settings, inside slots and chrome.
EVENT_COLORSconstantThe five palette keys and their token mappings.
springLinearfunctionThe damped spring sampled into a CSS linear() easing — the settle/cancel curve, exported.
KloqConfig / KloqSettingstypesProps in, resolved numbers out.

Slots & store

ExportKindNotes
DEFAULT_COMPONENTSconstantThe original slot implementations, so an override can wrap instead of replace.
KloqComponents + per-slot prop typestypesEventBlockProps, AllDayChipProps, EventPanelProps, TimeGutterProps, DayHeaderProps, NowIndicatorProps, TimelineBlockProps, ResourceGutterProps, TimelineHeaderProps, TimelineRowProps.
useKloqStore()hookThe event store, inside slots.
localStorageAdapter / STORAGE_KEY / eventsStorageKeyadapter + constant + functionThe default persistence, its default key, and the key under the current storage prefix.
SEED_EVENTS / buildSeedEvents / newEventIddata + functionsThe sample events and the id factory.
PersistenceAdapter / OnCommit / KloqChange / KloqStore / KloqBatchOptypesThe store's contracts — see Persistence and Optimistic sync.
isV2Event / migrateV1 / readPayload / PAYLOAD_VERSION / PayloadV2functions + constantsThe versioned localStorage payload and its migration.

Event model & instants

ExportKindNotes
CalEvent / TimedCalEvent / AllDayCalEvent / CalEventPatchtypesThe store event — a discriminated union on allDay.
Attendee / AttendeeStatus / EventColor / Instant / Reminder / ReminderMethodtypesThe field types on an event.
KloqView / KloqViewKind / ViewDescriptor / PlacedEvent / PlacedOccurrence / PlacementId / StoreId / WorkingHourstypesViews, placements and their branded ids. PlacedEvent.laneIndex / endLaneIndex are the row a placement sits on — a visible column in the calendar, a lane in a timeline. dayIndex / endDayIndex are the same values under their old name, kept for one release: @deprecated, removed next release.
DEFAULT_EVENT_COLOR / asPlacementId / isBusy / continuesBefore / continuesAfterconstants + functionsColor fallback, id branding, free/busy default, cross-midnight segment predicates.
instantAt / instantPlus / parseInstant / dateOnlyAt / dateOnlyAfter / toDateOnlyString / isDateOnly / daysBetween / minutesOfDate / wallMinutesBetweenfunctionsBuilding and reading instants, wall-clock-correct.
formatMinutes / formatRange / minutesToPx / pxToMinutes / resolveViewfunctionsTime labels and px↔minute geometry; TimeFormatOptions alongside.
HOUR_HEIGHT / SNAP_MIN / SNAP_FINE_MIN / MIN_EVENT_MINconstantsThe default geometry numbers.

Attendees & conflicts

ExportKindNotes
addAttendee / addAttendees / removeAttendee / findAttendeefunctionsList mutations; email is the dedupe key.
setAttendeeStatus / setAttendeeOptional / toggleAttendeeOptional / attendeeStatus / RSVP_CHOICESfunctions + constantRSVP state.
organizerOf / isOrganizer / attendeeLabel / initialsFor / isValidEmail / summarize / summaryLabel / AttendeeSummaryfunctions + typeReading and summarising an invite.
conflictBetween / isConflicting / findConflicts / conflictsFor / conflictClusters / describeConflictsfunctionsBusy-time collisions, attendee-aware; ConflictOptions / ConflictPair alongside.
eventInterval / intervalsOverlap / overlapMs / isBlocking / participantsOf / sharedParticipantsfunctionsThe interval layer under conflicts.

Commands, quick add, search, keyboard

ExportKindNotes
registerCommands / clearCommands / getCommands / subscribeCommands / KloqCommandfunctions + typeThe open ⌘K registry — see Command palette.
COMMAND_GROUPS / DEFAULT_COMMAND_GROUP / groupCommands / matchesQuery / normalizeQueryconstants + functionsThe palette's grouping and ranking model.
BUILT_IN_COMMANDS / commandAllowed / BuiltInCommandconstant + function + typeEvery built-in ⌘K id (families as :*) and the allowlist matcher behind commandPalette.commands.
parseQuickAdd / quickAddPreview / highlightSegments / UNTITLED / DEFAULT_QUICK_ADD_MINfunctions + constantsNatural-language event entry — see Quick add.
QUICK_ADD_KINDS / QUICK_ADD_KIND_ORDERconstantsEach token kind's label, swatch and underline mark, and the order a legend lists them in.
QuickAddInput / MoveToInputcomponentsThe quick-add field and the "move to…" field, standalone — see Quick add input. Both take announce (default true) to read their preview out as it changes.
searchEvents / EventSearchOptions / EventSearchResultfunction + typesWhole-store search, as ⌘K uses it.
formatWhen / formatEventWhen / formatDayLabel / formatDurationShort / allDayDisplayEndfunctionsThe shared "when" formatters.
KEY_ACTIONS / resolveKeymap / actionForEvent / bindingFromEvent / displayKey / isBindableKeyconstants + functionsThe remappable keyboard layer; Keymap / KeyActionId / ResolvedKeymap alongside.
parseMoveTarget / describeMovefunctions"Move to…" in plain language; MoveTarget / MoveToOptions alongside.
selectionFrom / selectOnly / toggleSelection / extendSelection / selectAll / eventsInMarquee / …functionsThe whole pure selection model (SelectionState) — click, ⇧-click, marquee.
writeEventsToClipboard / readEventsFromClipboard / eventsToICS / eventsToText / parseClipboardEvents / rebaseEvents / looksLikeICS / buildClipboardPayloadfunctionsCopy/paste, speaking ICS.

Views, navigation & layout

ExportKindNotes
viewKind / isTimeGridView / startOfWeek / MIN_N_DAY_VIEW / MAX_N_DAY_VIEW / MONTH_WEEKS / MONTH_DAYS / AGENDA_DAYS / YEAR_MONTHSfunctions + constantsView classification and bounds.
stepAnchor / todayAnchor / rangeOfView / formatViewTitle / stepLabel / isoWeek / isoWeekYearfunctionsRange stepping and titles; NavigationKeys / StepDirection alongside.
layoutMonth / hiddenOn / compareForDayfunctionsThe month grid's chip layout (MonthChip / MonthLayout).
groupAgendafunctionThe agenda grouping (Agenda / AgendaDay / AgendaEntry).
buildYearGrid / densityByDay / densityBucket / densityFill / describeLoad / loadOn / weekdayColumnsfunctionsThe year view's twelve mini-months and the heat-map density behind them.
YearViewcomponentThe year surface, standalone.
projectEventsfunctionPlacing store events into visible columns (Projection / DayBounds).
useIsClient()hookFalse on the server and the first client render — the SSR seam.
craftBus / CraftEvent / DragFrame / DragKindpub/sub + typesThe zero-render frame stream design mode reads.

Resource timeline

<Kloq> takes three more props for view="timeline", alongside KLOQ_PROPS above: lanes (readonly Lane[], empty by default — nothing renders without rows), laneAdapter (LaneAdapter, defaults to byResourceId()), and timelineWindow (TimelineWindowConfig, see Resource timeline for its two modes). The exports underneath:

ExportKindNotes
Lane / LaneAdaptertypesThe row-binding seam — see Resources & lanes.
byResourceIdfunctionThe default adapter: reads event.resourceId (or a named field) as the lane id.
resolveWindowfunctionProps in (TimelineWindowConfig + the anchor date), a concrete TimelineWindow out.
TimelineWindow / TimelineWindowConfigtypesThe resolved window and what a host passes for it.
KloqAxistypeThe shared px↔minute axis shape, used both vertically (the calendar) and horizontally (the timeline).
TimelineGrid / TimelineGridPropscomponent + typeThe row-laying-out grid beneath TimelineRow, exported for a standalone timeline outside <Kloq>. gutterWidth sets the sticky gutter's width in px (160 by default).
Warning

Everything the timeline needs to drive its own drag engine (projectTimeline, layoutLane, maxSubRows, ticksOf, zoomWindow, createHorizontalAxis) is deliberately not exported — the seam a host is meant to use is lanes / laneAdapter / timelineWindow plus the four slots, not the layout math underneath them.

Time zones, recurrence, ICS, reminders

These four areas have their own pages; the exports are enumerated there. Time zones: the full pure layer from wallClockIn to searchZones, plus MultiTimeZoneGutter and the authored-zone helpers. Recurrence: the RRULE library, the expansion seam, the this/following/all plans, RRuleBuilder and RecurrenceScopeDialog. ICS: toICS / downloadICS out, parseICS and its structural layer in. Reminders: normalization, descriptions and fire-time math from normalizeReminders to nextReminderAcross, plus the ReminderField control — kloq computes fire times, the host delivers.

Multi-calendar & accounts

ExportKindNotes
registerCalendarSources / registerCalendarAccounts / registerCalendarAccount / clearCalendarSourcesfunctionsA host registers whatever calendars it has connected — the component never owns provider auth.
getCalendarSources / getCalendarAccounts / subscribeCalendarSources / useCalendarSourcesfunctions + hookReading the registry, imperatively or reactively.
setCalendarVisible / toggleCalendarVisible / isVisible / visibleCalendarIds / isEventVisible / filterVisibleEventsfunctionsVisibility toggles and the filters they drive.
setDefaultCalendar / defaultCalendar / defaultCalendarId / newEventCalendarId / resolveDefaultCalendar / defaultAccount / accountDefaultCalendar / findAccount / findCalendarfunctionsWhere a new event lands.
resolveEventColor / groupByAccountfunctionsCalendar-tinted colors and the account grouping.
CalendarList / CalendarFieldcomponentsThe sidebar list and the panel's calendar picker, standalone.
CalendarSource / CalendarAccount / CalendarAccountGroup / CalendarColortypesThe registry's shapes.

@/components/kloq/lib/themes

ExportKindNotes
THEMES / getTheme / setThemedata + functionsNineteen KloqThemes and the persisted apply. Most of this is re-exported from the package root too.
getScheme / setScheme / toggleScheme / resolveScheme / watchSystemSchemefunctions"light" | "dark" | "system" — and the system watcher.
themeTransitionfunctionRuns a theme or scheme change inside one crossfade; applies it straight away where view transitions are missing or motion is reduced. Also exported from the package root.
THEME_RESTORE_SCRIPT / themeRestoreScriptconstant + functionInline <script> text that restores theme + scheme before first paint — zero-flash SSR. The function takes a storage prefix.
THEME_STORAGE_KEY / SCHEME_STORAGE_KEYconstantsThe default localStorage keys.
KloqTheme / KloqSchemetypesTheme metadata and the scheme union.

@/components/kloq/settings

ExportKindNotes
SettingsDialogcomponentThe optional preferences dialog (SettingsDialogProps, SettingsSection). Stores nothing — the host owns the state.
DEFAULT_PREFERENCES / LANGUAGE_OPTIONSconstantsThe KloqPreferences model — maps onto <Kloq> props — and the locale menu.
KloqPreferences / NavigationKeys / WeekStarttypesThe preference shapes.
disconnectAccount / setAccountConferencing / setAccountDefaultCalendar / setDefaultAccount / conferencingLabel / providerLabel / CONFERENCING_PROVIDERSfunctions + constantAccount-level mutations and labels for the accounts section.
SegmentedChoicecomponentThe segmented control the dialog's one-of-a-few choices use — a radio group with arrow-key navigation.

@/components/kloq/design-mode

ExportKindNotes
KloqDesignModecomponentThe whole ⌥D surface, standalone.
DesignModeProvider / useDesignMode / DesignModeOverlay / DesignModeHintcomponents + hookThe pieces, for custom tooling.
registerNetworkSim / getNetworkSim / subscribeNetworkSimfunctionsThe Network panel's latency/failure simulator (NetworkSimHandle) — how the demo's FakeServer shows up in the inspector.
Note

The source of truth is packages/kloq/src/index.ts — every export there carries a doc comment, and the sections above follow its grouping. If a name is here and not in your editor's autocomplete, update the package.