Features
Views
A resource timeline, a vertical time grid, an agenda list and a month calendar. Use one, offer several behind a switcher, or pair the calendar with the agenda.
Choosing a view
| Key | Layout | Spans | Best for |
|---|---|---|---|
timeline | Resources down, time across | day · week · month · year | Rosters, equipment, rooms, crews |
scheduler | Days across, hours down | day · week · month | Appointments, calendars, shifts |
agenda | A list grouped by day | day · week · month · year | Phones, print, “what’s next” |
calendar | Month or week grid of days | month · week | Overview, date picking |
Resource timeline
One row per resource, time running left to right. Rows grow to fit overlapping events, which stack into lanes. Rows are virtualized, so hundreds of resources scroll smoothly. With styleConfig.fitToWidth (the default) the axis stretches to the panel; past a minimum column width it scrolls horizontally instead.
<ProScheduler
data={events}
resources={people}
view={{
timeline: {
type: "month", // "day" | "week" | "month" | "year"
size: 1, // how many of them side by side
resolutionHorizontal: "day", // column unit: "hour" … "year"
dragTimeStep: 60,
},
}}
/>A month of assignments
Drag a bar to another person, stretch it from either end, or drag across an empty row to create one.
import { useMemo, useState, useSyncExternalStore } from "react"
import { ProScheduler, type SchedulerEvent } from "@/components/pro-scheduler"
import { studioAssignments, studioResources } from "@/lib/demo-data/studio"
const subscribe = () => () => {}
/** False during the server render and hydration, true afterwards. */
function useHydrated() {
return useSyncExternalStore(subscribe, () => true, () => false)
}
function Placeholder({ height }: { height: number }) {
return <div aria-hidden className="docs-demo__placeholder" style={{ height }} />
}
/**
* ProScheduler is controlled: it never edits `data` itself. The callbacks below
* are the whole contract — apply the change, and the view re-renders from it.
*/
function useEvents(initial: () => SchedulerEvent[]) {
const [events, setEvents] = useState(initial)
const handlers = useMemo(
() => ({
onEventCreated: (event: SchedulerEvent) =>
setEvents((list) => [...list, { ...event, id: crypto.randomUUID() }]),
onEventUpdated: (event: SchedulerEvent) =>
setEvents((list) => list.map((e) => (e.id === event.id ? event : e))),
onEventDeleted: (event: SchedulerEvent) =>
setEvents((list) => list.filter((e) => e.id !== event.id)),
}),
[]
)
return { events, setEvents, handlers }
}
export function TimelineDemo() {
const hydrated = useHydrated()
const { events, handlers } = useEvents(studioAssignments)
if (!hydrated) return <Placeholder height={560} />
return (
<ProScheduler
data={events}
resources={studioResources}
view={{ timeline: { type: "month" } }}
height={560}
{...handlers}
/>
)
}// 18 multi-day assignments across the month, one row per person.
type SchedulerEventId = string | number
type ResourceId = string | number
/** Accepts Date | ISO string | epoch ms; normalized to Date via {@link toDate}. */
type DateInput = Date | string | number
/** A row/grouping target. Extra keys are preserved (passthrough). */
interface SchedulerResource {
eventDragBetweenResources?: boolean
eventDragBetweenSlots?: boolean
eventDragInTime?: boolean
eventOverlap?: boolean
eventResize?: boolean
fixed?: boolean
reorder?: boolean
id: ResourceId
name: string
/** Accent color (hex/css), used for events lacking their own `color`. */
color?: string
/** Child resources: this one becomes a collapsible group (timeline). */
children?: SchedulerResource[]
/** Start this group collapsed. */
collapsed?: boolean
/** Set false to stop events being created on, or moved onto, this row. */
eventCreation?: boolean
/** Background of this resource's row (timeline) or columns (time grid). */
background?: string
/** Extra classes on this resource's row or columns. */
cssClass?: string
[key: string]: unknown
}
/** Everything an event has but its start (shared with dragged-in events). */
interface SchedulerEventFields {
cssClass?: string
cellCssClass?: string
textColor?: string
tooltip?: string
order?: number
timezone?: string
slot?: SlotId
dragBetweenResources?: boolean
dragBetweenSlots?: boolean
recurringExceptionRule?: PschRecurrence | string
id?: SchedulerEventId
title: string
/** Omit for point-in-time events: they are pinned at `start`, never resizable,
* and (in the scheduler view's auto mode) overlap-packed by rendered height. */
end?: DateInput
/** The resource it's booked on — or several, for a shared event (a meeting
* with three people shows in each of their rows or columns). */
resource?: ResourceId | ResourceId[]
color?: string
allDay?: boolean
/** Set false to lock this event: it renders but can't be moved or resized. */
editable?: boolean
/** Set false to keep the duration fixed: the event moves but can't be resized. */
resize?: boolean
/** Set false so moving can't change the time — only the resource (timeline).
* In the time grid, where a move always changes the time, the event is fixed. */
dragInTime?: boolean
/** Set false so moving can't change the resource — only the time. */
resourceEditable?: boolean
/** Minutes kept free before / after the event (travel, set-up, cleaning).
* Drawn as a hatched band, and counted when `eventOverlap` is false. */
bufferBefore?: number
bufferAfter?: number
/** Set false to refuse any overlap with this event, whatever `eventOverlap` says. */
overlap?: boolean
/** Repeat the event: a rule object, or an RRULE string such as
* "FREQ=WEEKLY;BYDAY=MO,WE;COUNT=10". `start`/`end` are the first occurrence. */
recurring?: PschRecurrence | string
/** Days left out of the series: "YYYY-MM-DD" strings or dates. */
recurringException?: DateInput | DateInput[]
/** Set on displayed occurrences: the `id` of the series they belong to. */
recurringEventId?: SchedulerEventId
[key: string]: unknown
}
interface SchedulerEvent extends SchedulerEventFields {
start: DateInput
}
/** A repeat rule — the object form of an RRULE. */
interface PschRecurrence {
from?: DateInput
weekStart?: number
repeat: "daily" | "weekly" | "monthly" | "yearly"
/** Every n days / weeks / months / years (default 1). */
interval?: number
/** Stop after this many occurrences (exceptions included). */
count?: number
/** Stop after this date. */
until?: DateInput
/** Weekdays: "MO,WE,FR" or [1, 3, 5] (0 = Sunday). In monthly and yearly
* rules an ordinal picks one: "2TU" (second Tuesday), "-1FR" (last Friday). */
weekDays?: string | number[]
/** Day(s) of the month; negative counts from the end (-1 = the last day). */
day?: number | number[]
/** Month(s) of a yearly rule, 1–12. */
month?: number | number[]
/** Pick the nth of the matching days in each period (-1 = the last), e.g.
* the last weekday of the month with `weekDays: "MO,TU,WE,TH,FR", pos: -1`. */
pos?: number
}
type SlotId = string | number
// The demos extend both with fields of their own — extra keys are kept
// and handed back to you on every callback.
import type { SchedulerEvent, SchedulerResource } from "@/components/pro-scheduler"
type StudioResource = SchedulerResource & {
id: string
name: string
role: string
color: string
}
type StudioEvent = SchedulerEvent & {
id: string
title: string
start: Date
end?: Date
resource: string
client: string
kind: "Shoot" | "Edit" | "Review" | "Pitch" | "Travel" | "Workshop"
}
const resources: StudioResource[] = [
{"id":"ada","name":"Ada Moreno","role":"Director","color":"#2563eb"},
{"id":"ben","name":"Ben Okafor","role":"Producer","color":"#059669"},
{"id":"chloe","name":"Chloé Martin","role":"Editor","color":"#d97706"},
// …5 more people
]
const events: StudioEvent[] = [
{
"id": "a-1",
"title": "Lumen Labs: design system",
"client": "Lumen Labs",
"kind": "Workshop",
"resource": "hana",
"start": "2026-09-01T09:00:00.000Z",
"end": "2026-09-05T18:00:00.000Z",
"allDay": true
},
{
"id": "a-2",
"title": "Aurora Bank: edit",
"client": "Aurora Bank",
"kind": "Edit",
"resource": "chloe",
"start": "2026-09-02T09:00:00.000Z",
"end": "2026-09-10T18:00:00.000Z",
"allDay": true
},
{
"id": "a-3",
"title": "Harbor Coffee: production",
"client": "Harbor Coffee",
"kind": "Shoot",
"resource": "ada",
"start": "2026-09-03T09:00:00.000Z",
"end": "2026-09-07T18:00:00.000Z",
"allDay": true
},
// …15 more events
]Time grid (day, week, month)
Days as columns, hours down the side — the classic calendar week. Overlapping events share the column side by side. timeCellStep sets the grid granularity; dragTimeStep sets what interactions snap to, independently.
view={{
scheduler: {
type: "week", // "day" | "week" | "month"
startTime: "07:00",
endTime: "20:00", // may run past midnight: "26:00"
timeCellStep: 30, // grid granularity, in minutes
timeLabelStep: 60,
dragTimeStep: 15, // what move / resize / create snap to
startDay: 1, endDay: 5, // Monday to Friday only
allDay: true, // the all-day strip under the day headers
currentTimeIndicator: true,
cursorTime: true,
gridLines: "both", // "horizontal" | "vertical" | "none"
fitToHeight: false, // true: whole range fits, no vertical scroll
eventHeight: "duration", // "auto": pinned at start, sized to content
},
}}Periods: a school bell
When the day runs on fixed periods rather than a clock, pass them as periods. The time labels and lines follow the periods and the gaps between them are shaded. Moves, drops from outside, resizes and new events snap to them instead of dragTimeStep: an event starts on a period, and one longer than a period only where back-to-back periods hold it — a 90-minute lesson takes a double period and never straddles a break. Gaps aren't blocked; add an invalid range for that (lunch, say). The school timetable on the home page runs on this bell.
view={{
scheduler: {
type: "week",
startDay: 1, endDay: 5,
startTime: "08:15",
endTime: "18:45",
// A school bell: 45-minute periods, breaks of different lengths.
periods: [
{ start: "08:30", end: "09:15" }, { start: "09:15", end: "10:00" },
{ start: "10:30", end: "11:15" }, { start: "11:15", end: "12:00" },
{ start: "12:15", end: "13:00" },
{ start: "14:00", end: "14:45" },
{ start: "15:00", end: "15:45" }, { start: "15:45", end: "16:30" },
{ start: "16:45", end: "17:30" }, { start: "17:45", end: "18:30" },
],
},
}}Week view
07:00–20:00 in half-hour cells, 15-minute snapping, a current-time line and a cursor time readout.
import { useMemo, useState, useSyncExternalStore } from "react"
import { ProScheduler, type SchedulerEvent } from "@/components/pro-scheduler"
import { studioResources, studioSessions } from "@/lib/demo-data/studio"
const subscribe = () => () => {}
/** False during the server render and hydration, true afterwards. */
function useHydrated() {
return useSyncExternalStore(subscribe, () => true, () => false)
}
function Placeholder({ height }: { height: number }) {
return <div aria-hidden className="docs-demo__placeholder" style={{ height }} />
}
/**
* ProScheduler is controlled: it never edits `data` itself. The callbacks below
* are the whole contract — apply the change, and the view re-renders from it.
*/
function useEvents(initial: () => SchedulerEvent[]) {
const [events, setEvents] = useState(initial)
const handlers = useMemo(
() => ({
onEventCreated: (event: SchedulerEvent) =>
setEvents((list) => [...list, { ...event, id: crypto.randomUUID() }]),
onEventUpdated: (event: SchedulerEvent) =>
setEvents((list) => list.map((e) => (e.id === event.id ? event : e))),
onEventDeleted: (event: SchedulerEvent) =>
setEvents((list) => list.filter((e) => e.id !== event.id)),
}),
[]
)
return { events, setEvents, handlers }
}
export function WeekDemo() {
const hydrated = useHydrated()
const { events, handlers } = useEvents(studioSessions)
if (!hydrated) return <Placeholder height={620} />
return (
<ProScheduler
data={events}
resources={studioResources}
view={{
scheduler: {
type: "week",
startTime: "07:00",
endTime: "20:00",
timeCellStep: 30,
dragTimeStep: 15,
currentTimeIndicator: true,
cursorTime: true,
},
}}
height={620}
{...handlers}
/>
)
}// 20 timed sessions around the current week.
type SchedulerEventId = string | number
type ResourceId = string | number
/** Accepts Date | ISO string | epoch ms; normalized to Date via {@link toDate}. */
type DateInput = Date | string | number
/** A row/grouping target. Extra keys are preserved (passthrough). */
interface SchedulerResource {
eventDragBetweenResources?: boolean
eventDragBetweenSlots?: boolean
eventDragInTime?: boolean
eventOverlap?: boolean
eventResize?: boolean
fixed?: boolean
reorder?: boolean
id: ResourceId
name: string
/** Accent color (hex/css), used for events lacking their own `color`. */
color?: string
/** Child resources: this one becomes a collapsible group (timeline). */
children?: SchedulerResource[]
/** Start this group collapsed. */
collapsed?: boolean
/** Set false to stop events being created on, or moved onto, this row. */
eventCreation?: boolean
/** Background of this resource's row (timeline) or columns (time grid). */
background?: string
/** Extra classes on this resource's row or columns. */
cssClass?: string
[key: string]: unknown
}
/** Everything an event has but its start (shared with dragged-in events). */
interface SchedulerEventFields {
cssClass?: string
cellCssClass?: string
textColor?: string
tooltip?: string
order?: number
timezone?: string
slot?: SlotId
dragBetweenResources?: boolean
dragBetweenSlots?: boolean
recurringExceptionRule?: PschRecurrence | string
id?: SchedulerEventId
title: string
/** Omit for point-in-time events: they are pinned at `start`, never resizable,
* and (in the scheduler view's auto mode) overlap-packed by rendered height. */
end?: DateInput
/** The resource it's booked on — or several, for a shared event (a meeting
* with three people shows in each of their rows or columns). */
resource?: ResourceId | ResourceId[]
color?: string
allDay?: boolean
/** Set false to lock this event: it renders but can't be moved or resized. */
editable?: boolean
/** Set false to keep the duration fixed: the event moves but can't be resized. */
resize?: boolean
/** Set false so moving can't change the time — only the resource (timeline).
* In the time grid, where a move always changes the time, the event is fixed. */
dragInTime?: boolean
/** Set false so moving can't change the resource — only the time. */
resourceEditable?: boolean
/** Minutes kept free before / after the event (travel, set-up, cleaning).
* Drawn as a hatched band, and counted when `eventOverlap` is false. */
bufferBefore?: number
bufferAfter?: number
/** Set false to refuse any overlap with this event, whatever `eventOverlap` says. */
overlap?: boolean
/** Repeat the event: a rule object, or an RRULE string such as
* "FREQ=WEEKLY;BYDAY=MO,WE;COUNT=10". `start`/`end` are the first occurrence. */
recurring?: PschRecurrence | string
/** Days left out of the series: "YYYY-MM-DD" strings or dates. */
recurringException?: DateInput | DateInput[]
/** Set on displayed occurrences: the `id` of the series they belong to. */
recurringEventId?: SchedulerEventId
[key: string]: unknown
}
interface SchedulerEvent extends SchedulerEventFields {
start: DateInput
}
/** A repeat rule — the object form of an RRULE. */
interface PschRecurrence {
from?: DateInput
weekStart?: number
repeat: "daily" | "weekly" | "monthly" | "yearly"
/** Every n days / weeks / months / years (default 1). */
interval?: number
/** Stop after this many occurrences (exceptions included). */
count?: number
/** Stop after this date. */
until?: DateInput
/** Weekdays: "MO,WE,FR" or [1, 3, 5] (0 = Sunday). In monthly and yearly
* rules an ordinal picks one: "2TU" (second Tuesday), "-1FR" (last Friday). */
weekDays?: string | number[]
/** Day(s) of the month; negative counts from the end (-1 = the last day). */
day?: number | number[]
/** Month(s) of a yearly rule, 1–12. */
month?: number | number[]
/** Pick the nth of the matching days in each period (-1 = the last), e.g.
* the last weekday of the month with `weekDays: "MO,TU,WE,TH,FR", pos: -1`. */
pos?: number
}
type SlotId = string | number
// The demos extend both with fields of their own — extra keys are kept
// and handed back to you on every callback.
import type { SchedulerEvent, SchedulerResource } from "@/components/pro-scheduler"
type StudioResource = SchedulerResource & {
id: string
name: string
role: string
color: string
}
type StudioEvent = SchedulerEvent & {
id: string
title: string
start: Date
end?: Date
resource: string
client: string
kind: "Shoot" | "Edit" | "Review" | "Pitch" | "Travel" | "Workshop"
}
const events: StudioEvent[] = [
{
"id": "s-1",
"title": "Kickoff call",
"client": "Harbor Coffee",
"kind": "Pitch",
"resource": "ben",
"start": "2026-09-28T09:00:00.000Z",
"end": "2026-09-28T10:00:00.000Z"
},
{
"id": "s-2",
"title": "Location scout",
"client": "Harbor Coffee",
"kind": "Travel",
"resource": "ada",
"start": "2026-09-28T11:00:00.000Z",
"end": "2026-09-28T14:00:00.000Z"
},
{
"id": "s-3",
"title": "Rough cut review",
"client": "Aurora Bank",
"kind": "Review",
"resource": "chloe",
"start": "2026-09-28T15:00:00.000Z",
"end": "2026-09-28T16:30:00.000Z"
},
// …17 more events
]Agenda
A virtualized list of events grouped by day, spanning the type and size you choose. Empty days are skipped unless showEmptyDays is set.
view={{ agenda: { type: "week", size: 2, showEmptyDays: false } }}Two weeks as a list
Page forward, open an event to edit it.
import { useMemo, useState, useSyncExternalStore } from "react"
import { ProScheduler, type SchedulerEvent } from "@/components/pro-scheduler"
import { studioResources, studioSessions } from "@/lib/demo-data/studio"
const subscribe = () => () => {}
/** False during the server render and hydration, true afterwards. */
function useHydrated() {
return useSyncExternalStore(subscribe, () => true, () => false)
}
function Placeholder({ height }: { height: number }) {
return <div aria-hidden className="docs-demo__placeholder" style={{ height }} />
}
/**
* ProScheduler is controlled: it never edits `data` itself. The callbacks below
* are the whole contract — apply the change, and the view re-renders from it.
*/
function useEvents(initial: () => SchedulerEvent[]) {
const [events, setEvents] = useState(initial)
const handlers = useMemo(
() => ({
onEventCreated: (event: SchedulerEvent) =>
setEvents((list) => [...list, { ...event, id: crypto.randomUUID() }]),
onEventUpdated: (event: SchedulerEvent) =>
setEvents((list) => list.map((e) => (e.id === event.id ? event : e))),
onEventDeleted: (event: SchedulerEvent) =>
setEvents((list) => list.filter((e) => e.id !== event.id)),
}),
[]
)
return { events, setEvents, handlers }
}
export function AgendaDemo() {
const hydrated = useHydrated()
const { events, handlers } = useEvents(studioSessions)
if (!hydrated) return <Placeholder height={520} />
return (
<ProScheduler
data={events}
resources={studioResources}
view={{ agenda: { type: "week", size: 2 } }}
height={520}
{...handlers}
/>
)
}// The same sessions, listed by day. Days without events are skipped
// unless `showEmptyDays` is set.
type SchedulerEventId = string | number
type ResourceId = string | number
/** Accepts Date | ISO string | epoch ms; normalized to Date via {@link toDate}. */
type DateInput = Date | string | number
/** A row/grouping target. Extra keys are preserved (passthrough). */
interface SchedulerResource {
eventDragBetweenResources?: boolean
eventDragBetweenSlots?: boolean
eventDragInTime?: boolean
eventOverlap?: boolean
eventResize?: boolean
fixed?: boolean
reorder?: boolean
id: ResourceId
name: string
/** Accent color (hex/css), used for events lacking their own `color`. */
color?: string
/** Child resources: this one becomes a collapsible group (timeline). */
children?: SchedulerResource[]
/** Start this group collapsed. */
collapsed?: boolean
/** Set false to stop events being created on, or moved onto, this row. */
eventCreation?: boolean
/** Background of this resource's row (timeline) or columns (time grid). */
background?: string
/** Extra classes on this resource's row or columns. */
cssClass?: string
[key: string]: unknown
}
/** Everything an event has but its start (shared with dragged-in events). */
interface SchedulerEventFields {
cssClass?: string
cellCssClass?: string
textColor?: string
tooltip?: string
order?: number
timezone?: string
slot?: SlotId
dragBetweenResources?: boolean
dragBetweenSlots?: boolean
recurringExceptionRule?: PschRecurrence | string
id?: SchedulerEventId
title: string
/** Omit for point-in-time events: they are pinned at `start`, never resizable,
* and (in the scheduler view's auto mode) overlap-packed by rendered height. */
end?: DateInput
/** The resource it's booked on — or several, for a shared event (a meeting
* with three people shows in each of their rows or columns). */
resource?: ResourceId | ResourceId[]
color?: string
allDay?: boolean
/** Set false to lock this event: it renders but can't be moved or resized. */
editable?: boolean
/** Set false to keep the duration fixed: the event moves but can't be resized. */
resize?: boolean
/** Set false so moving can't change the time — only the resource (timeline).
* In the time grid, where a move always changes the time, the event is fixed. */
dragInTime?: boolean
/** Set false so moving can't change the resource — only the time. */
resourceEditable?: boolean
/** Minutes kept free before / after the event (travel, set-up, cleaning).
* Drawn as a hatched band, and counted when `eventOverlap` is false. */
bufferBefore?: number
bufferAfter?: number
/** Set false to refuse any overlap with this event, whatever `eventOverlap` says. */
overlap?: boolean
/** Repeat the event: a rule object, or an RRULE string such as
* "FREQ=WEEKLY;BYDAY=MO,WE;COUNT=10". `start`/`end` are the first occurrence. */
recurring?: PschRecurrence | string
/** Days left out of the series: "YYYY-MM-DD" strings or dates. */
recurringException?: DateInput | DateInput[]
/** Set on displayed occurrences: the `id` of the series they belong to. */
recurringEventId?: SchedulerEventId
[key: string]: unknown
}
interface SchedulerEvent extends SchedulerEventFields {
start: DateInput
}
/** A repeat rule — the object form of an RRULE. */
interface PschRecurrence {
from?: DateInput
weekStart?: number
repeat: "daily" | "weekly" | "monthly" | "yearly"
/** Every n days / weeks / months / years (default 1). */
interval?: number
/** Stop after this many occurrences (exceptions included). */
count?: number
/** Stop after this date. */
until?: DateInput
/** Weekdays: "MO,WE,FR" or [1, 3, 5] (0 = Sunday). In monthly and yearly
* rules an ordinal picks one: "2TU" (second Tuesday), "-1FR" (last Friday). */
weekDays?: string | number[]
/** Day(s) of the month; negative counts from the end (-1 = the last day). */
day?: number | number[]
/** Month(s) of a yearly rule, 1–12. */
month?: number | number[]
/** Pick the nth of the matching days in each period (-1 = the last), e.g.
* the last weekday of the month with `weekDays: "MO,TU,WE,TH,FR", pos: -1`. */
pos?: number
}
type SlotId = string | number
// The demos extend both with fields of their own — extra keys are kept
// and handed back to you on every callback.
import type { SchedulerEvent, SchedulerResource } from "@/components/pro-scheduler"
type StudioResource = SchedulerResource & {
id: string
name: string
role: string
color: string
}
type StudioEvent = SchedulerEvent & {
id: string
title: string
start: Date
end?: Date
resource: string
client: string
kind: "Shoot" | "Edit" | "Review" | "Pitch" | "Travel" | "Workshop"
}
const events: StudioEvent[] = [
{
"id": "s-1",
"title": "Kickoff call",
"client": "Harbor Coffee",
"kind": "Pitch",
"resource": "ben",
"start": "2026-09-28T09:00:00.000Z",
"end": "2026-09-28T10:00:00.000Z"
},
{
"id": "s-2",
"title": "Location scout",
"client": "Harbor Coffee",
"kind": "Travel",
"resource": "ada",
"start": "2026-09-28T11:00:00.000Z",
"end": "2026-09-28T14:00:00.000Z"
},
{
"id": "s-3",
"title": "Rough cut review",
"client": "Aurora Bank",
"kind": "Review",
"resource": "chloe",
"start": "2026-09-28T15:00:00.000Z",
"end": "2026-09-28T16:30:00.000Z"
},
// …17 more events
]Calendar, with or without agenda
A month (or single-week) grid of days with an event count on each. Picking a day selects it; with agenda alongside, that day’s events list underneath and both share one navigation. panelDragNavigate lets a sideways swipe page the months.
// Grid on top, the selected day's list underneath, one navigation.
view={{
calendar: { type: "month", panelDragNavigate: true },
agenda: { type: "day" },
}}Month calendar with agenda
Pick a day to list its events; swipe the grid to change month.
import { useMemo, useState, useSyncExternalStore } from "react"
import { ProScheduler, type SchedulerEvent } from "@/components/pro-scheduler"
import { studioEvents, studioResources } from "@/lib/demo-data/studio"
const subscribe = () => () => {}
/** False during the server render and hydration, true afterwards. */
function useHydrated() {
return useSyncExternalStore(subscribe, () => true, () => false)
}
function Placeholder({ height }: { height: number }) {
return <div aria-hidden className="docs-demo__placeholder" style={{ height }} />
}
/**
* ProScheduler is controlled: it never edits `data` itself. The callbacks below
* are the whole contract — apply the change, and the view re-renders from it.
*/
function useEvents(initial: () => SchedulerEvent[]) {
const [events, setEvents] = useState(initial)
const handlers = useMemo(
() => ({
onEventCreated: (event: SchedulerEvent) =>
setEvents((list) => [...list, { ...event, id: crypto.randomUUID() }]),
onEventUpdated: (event: SchedulerEvent) =>
setEvents((list) => list.map((e) => (e.id === event.id ? event : e))),
onEventDeleted: (event: SchedulerEvent) =>
setEvents((list) => list.filter((e) => e.id !== event.id)),
}),
[]
)
return { events, setEvents, handlers }
}
export function CalendarDemo() {
const hydrated = useHydrated()
const { events, handlers } = useEvents(studioEvents)
if (!hydrated) return <Placeholder height={680} />
return (
<ProScheduler
data={events}
resources={studioResources}
// A month grid on top, the selected day's events below — one navigation.
view={{ calendar: { type: "month", panelDragNavigate: true }, agenda: { type: "day" } }}
height={680}
{...handlers}
/>
)
}// Sessions and assignments together — 38 events.
type SchedulerEventId = string | number
type ResourceId = string | number
/** Accepts Date | ISO string | epoch ms; normalized to Date via {@link toDate}. */
type DateInput = Date | string | number
/** A row/grouping target. Extra keys are preserved (passthrough). */
interface SchedulerResource {
eventDragBetweenResources?: boolean
eventDragBetweenSlots?: boolean
eventDragInTime?: boolean
eventOverlap?: boolean
eventResize?: boolean
fixed?: boolean
reorder?: boolean
id: ResourceId
name: string
/** Accent color (hex/css), used for events lacking their own `color`. */
color?: string
/** Child resources: this one becomes a collapsible group (timeline). */
children?: SchedulerResource[]
/** Start this group collapsed. */
collapsed?: boolean
/** Set false to stop events being created on, or moved onto, this row. */
eventCreation?: boolean
/** Background of this resource's row (timeline) or columns (time grid). */
background?: string
/** Extra classes on this resource's row or columns. */
cssClass?: string
[key: string]: unknown
}
/** Everything an event has but its start (shared with dragged-in events). */
interface SchedulerEventFields {
cssClass?: string
cellCssClass?: string
textColor?: string
tooltip?: string
order?: number
timezone?: string
slot?: SlotId
dragBetweenResources?: boolean
dragBetweenSlots?: boolean
recurringExceptionRule?: PschRecurrence | string
id?: SchedulerEventId
title: string
/** Omit for point-in-time events: they are pinned at `start`, never resizable,
* and (in the scheduler view's auto mode) overlap-packed by rendered height. */
end?: DateInput
/** The resource it's booked on — or several, for a shared event (a meeting
* with three people shows in each of their rows or columns). */
resource?: ResourceId | ResourceId[]
color?: string
allDay?: boolean
/** Set false to lock this event: it renders but can't be moved or resized. */
editable?: boolean
/** Set false to keep the duration fixed: the event moves but can't be resized. */
resize?: boolean
/** Set false so moving can't change the time — only the resource (timeline).
* In the time grid, where a move always changes the time, the event is fixed. */
dragInTime?: boolean
/** Set false so moving can't change the resource — only the time. */
resourceEditable?: boolean
/** Minutes kept free before / after the event (travel, set-up, cleaning).
* Drawn as a hatched band, and counted when `eventOverlap` is false. */
bufferBefore?: number
bufferAfter?: number
/** Set false to refuse any overlap with this event, whatever `eventOverlap` says. */
overlap?: boolean
/** Repeat the event: a rule object, or an RRULE string such as
* "FREQ=WEEKLY;BYDAY=MO,WE;COUNT=10". `start`/`end` are the first occurrence. */
recurring?: PschRecurrence | string
/** Days left out of the series: "YYYY-MM-DD" strings or dates. */
recurringException?: DateInput | DateInput[]
/** Set on displayed occurrences: the `id` of the series they belong to. */
recurringEventId?: SchedulerEventId
[key: string]: unknown
}
interface SchedulerEvent extends SchedulerEventFields {
start: DateInput
}
/** A repeat rule — the object form of an RRULE. */
interface PschRecurrence {
from?: DateInput
weekStart?: number
repeat: "daily" | "weekly" | "monthly" | "yearly"
/** Every n days / weeks / months / years (default 1). */
interval?: number
/** Stop after this many occurrences (exceptions included). */
count?: number
/** Stop after this date. */
until?: DateInput
/** Weekdays: "MO,WE,FR" or [1, 3, 5] (0 = Sunday). In monthly and yearly
* rules an ordinal picks one: "2TU" (second Tuesday), "-1FR" (last Friday). */
weekDays?: string | number[]
/** Day(s) of the month; negative counts from the end (-1 = the last day). */
day?: number | number[]
/** Month(s) of a yearly rule, 1–12. */
month?: number | number[]
/** Pick the nth of the matching days in each period (-1 = the last), e.g.
* the last weekday of the month with `weekDays: "MO,TU,WE,TH,FR", pos: -1`. */
pos?: number
}
type SlotId = string | number
// The demos extend both with fields of their own — extra keys are kept
// and handed back to you on every callback.
import type { SchedulerEvent, SchedulerResource } from "@/components/pro-scheduler"
type StudioResource = SchedulerResource & {
id: string
name: string
role: string
color: string
}
type StudioEvent = SchedulerEvent & {
id: string
title: string
start: Date
end?: Date
resource: string
client: string
kind: "Shoot" | "Edit" | "Review" | "Pitch" | "Travel" | "Workshop"
}
const events: StudioEvent[] = [
{
"id": "a-1",
"title": "Lumen Labs: design system",
"client": "Lumen Labs",
"kind": "Workshop",
"resource": "hana",
"start": "2026-09-01T09:00:00.000Z",
"end": "2026-09-05T18:00:00.000Z",
"allDay": true
},
{
"id": "a-2",
"title": "Aurora Bank: edit",
"client": "Aurora Bank",
"kind": "Edit",
"resource": "chloe",
"start": "2026-09-02T09:00:00.000Z",
"end": "2026-09-10T18:00:00.000Z",
"allDay": true
},
{
"id": "a-3",
"title": "Harbor Coffee: production",
"client": "Harbor Coffee",
"kind": "Shoot",
"resource": "ada",
"start": "2026-09-03T09:00:00.000Z",
"end": "2026-09-07T18:00:00.000Z",
"allDay": true
},
// …35 more events
]Several views, one scheduler
Put more than one key in view and the header grows a view switcher. The selected date carries across, so switching from the week to the timeline keeps you on the same week.
view={{
scheduler: { type: "week", startTime: "07:00", endTime: "20:00" },
timeline: { type: "month" },
agenda: { type: "month" },
}}
defaultView="scheduler" // otherwise the timeline would open firstWeek, timeline and agenda
Use the switcher at the top right.
import { useMemo, useState, useSyncExternalStore } from "react"
import { ProScheduler, type SchedulerEvent } from "@/components/pro-scheduler"
import { studioEvents, studioResources } from "@/lib/demo-data/studio"
const subscribe = () => () => {}
/** False during the server render and hydration, true afterwards. */
function useHydrated() {
return useSyncExternalStore(subscribe, () => true, () => false)
}
function Placeholder({ height }: { height: number }) {
return <div aria-hidden className="docs-demo__placeholder" style={{ height }} />
}
/**
* ProScheduler is controlled: it never edits `data` itself. The callbacks below
* are the whole contract — apply the change, and the view re-renders from it.
*/
function useEvents(initial: () => SchedulerEvent[]) {
const [events, setEvents] = useState(initial)
const handlers = useMemo(
() => ({
onEventCreated: (event: SchedulerEvent) =>
setEvents((list) => [...list, { ...event, id: crypto.randomUUID() }]),
onEventUpdated: (event: SchedulerEvent) =>
setEvents((list) => list.map((e) => (e.id === event.id ? event : e))),
onEventDeleted: (event: SchedulerEvent) =>
setEvents((list) => list.filter((e) => e.id !== event.id)),
}),
[]
)
return { events, setEvents, handlers }
}
export function MultiViewDemo({ height = 640 }: { height?: number }) {
const hydrated = useHydrated()
const { events, handlers } = useEvents(studioEvents)
if (!hydrated) return <Placeholder height={height} />
return (
<ProScheduler
data={events}
resources={studioResources}
view={{
scheduler: { type: "week", startTime: "07:00", endTime: "20:00", dragTimeStep: 15 },
timeline: { type: "month" },
agenda: { type: "month" },
}}
defaultView="scheduler"
height={height}
{...handlers}
/>
)
}// One dataset, three views. Switching view never changes `data`.
type SchedulerEventId = string | number
type ResourceId = string | number
/** Accepts Date | ISO string | epoch ms; normalized to Date via {@link toDate}. */
type DateInput = Date | string | number
/** A row/grouping target. Extra keys are preserved (passthrough). */
interface SchedulerResource {
eventDragBetweenResources?: boolean
eventDragBetweenSlots?: boolean
eventDragInTime?: boolean
eventOverlap?: boolean
eventResize?: boolean
fixed?: boolean
reorder?: boolean
id: ResourceId
name: string
/** Accent color (hex/css), used for events lacking their own `color`. */
color?: string
/** Child resources: this one becomes a collapsible group (timeline). */
children?: SchedulerResource[]
/** Start this group collapsed. */
collapsed?: boolean
/** Set false to stop events being created on, or moved onto, this row. */
eventCreation?: boolean
/** Background of this resource's row (timeline) or columns (time grid). */
background?: string
/** Extra classes on this resource's row or columns. */
cssClass?: string
[key: string]: unknown
}
/** Everything an event has but its start (shared with dragged-in events). */
interface SchedulerEventFields {
cssClass?: string
cellCssClass?: string
textColor?: string
tooltip?: string
order?: number
timezone?: string
slot?: SlotId
dragBetweenResources?: boolean
dragBetweenSlots?: boolean
recurringExceptionRule?: PschRecurrence | string
id?: SchedulerEventId
title: string
/** Omit for point-in-time events: they are pinned at `start`, never resizable,
* and (in the scheduler view's auto mode) overlap-packed by rendered height. */
end?: DateInput
/** The resource it's booked on — or several, for a shared event (a meeting
* with three people shows in each of their rows or columns). */
resource?: ResourceId | ResourceId[]
color?: string
allDay?: boolean
/** Set false to lock this event: it renders but can't be moved or resized. */
editable?: boolean
/** Set false to keep the duration fixed: the event moves but can't be resized. */
resize?: boolean
/** Set false so moving can't change the time — only the resource (timeline).
* In the time grid, where a move always changes the time, the event is fixed. */
dragInTime?: boolean
/** Set false so moving can't change the resource — only the time. */
resourceEditable?: boolean
/** Minutes kept free before / after the event (travel, set-up, cleaning).
* Drawn as a hatched band, and counted when `eventOverlap` is false. */
bufferBefore?: number
bufferAfter?: number
/** Set false to refuse any overlap with this event, whatever `eventOverlap` says. */
overlap?: boolean
/** Repeat the event: a rule object, or an RRULE string such as
* "FREQ=WEEKLY;BYDAY=MO,WE;COUNT=10". `start`/`end` are the first occurrence. */
recurring?: PschRecurrence | string
/** Days left out of the series: "YYYY-MM-DD" strings or dates. */
recurringException?: DateInput | DateInput[]
/** Set on displayed occurrences: the `id` of the series they belong to. */
recurringEventId?: SchedulerEventId
[key: string]: unknown
}
interface SchedulerEvent extends SchedulerEventFields {
start: DateInput
}
/** A repeat rule — the object form of an RRULE. */
interface PschRecurrence {
from?: DateInput
weekStart?: number
repeat: "daily" | "weekly" | "monthly" | "yearly"
/** Every n days / weeks / months / years (default 1). */
interval?: number
/** Stop after this many occurrences (exceptions included). */
count?: number
/** Stop after this date. */
until?: DateInput
/** Weekdays: "MO,WE,FR" or [1, 3, 5] (0 = Sunday). In monthly and yearly
* rules an ordinal picks one: "2TU" (second Tuesday), "-1FR" (last Friday). */
weekDays?: string | number[]
/** Day(s) of the month; negative counts from the end (-1 = the last day). */
day?: number | number[]
/** Month(s) of a yearly rule, 1–12. */
month?: number | number[]
/** Pick the nth of the matching days in each period (-1 = the last), e.g.
* the last weekday of the month with `weekDays: "MO,TU,WE,TH,FR", pos: -1`. */
pos?: number
}
type SlotId = string | number
// The demos extend both with fields of their own — extra keys are kept
// and handed back to you on every callback.
import type { SchedulerEvent, SchedulerResource } from "@/components/pro-scheduler"
type StudioResource = SchedulerResource & {
id: string
name: string
role: string
color: string
}
type StudioEvent = SchedulerEvent & {
id: string
title: string
start: Date
end?: Date
resource: string
client: string
kind: "Shoot" | "Edit" | "Review" | "Pitch" | "Travel" | "Workshop"
}
const resources: StudioResource[] = [
{"id":"ada","name":"Ada Moreno","role":"Director","color":"#2563eb"},
{"id":"ben","name":"Ben Okafor","role":"Producer","color":"#059669"},
{"id":"chloe","name":"Chloé Martin","role":"Editor","color":"#d97706"},
// …5 more people
]
const events: StudioEvent[] = [
{
"id": "a-1",
"title": "Lumen Labs: design system",
"client": "Lumen Labs",
"kind": "Workshop",
"resource": "hana",
"start": "2026-09-01T09:00:00.000Z",
"end": "2026-09-05T18:00:00.000Z",
"allDay": true
},
{
"id": "a-2",
"title": "Aurora Bank: edit",
"client": "Aurora Bank",
"kind": "Edit",
"resource": "chloe",
"start": "2026-09-02T09:00:00.000Z",
"end": "2026-09-10T18:00:00.000Z",
"allDay": true
},
{
"id": "a-3",
"title": "Harbor Coffee: production",
"client": "Harbor Coffee",
"kind": "Shoot",
"resource": "ada",
"start": "2026-09-03T09:00:00.000Z",
"end": "2026-09-07T18:00:00.000Z",
"allDay": true
},
// …35 more events
]