Features
Resources
People, rooms, vehicles or machines: rows in the timeline, columns in the time grid, groups that collapse, and events shared between several of them.
Declaring resources
Pass resources and point each event at one — or several — with resource. An event’s own color wins over its resource’s.
type SchedulerResource = {
id: string | number
name: string
color?: string // used by events that have no colour of their own
children?: SchedulerResource[] // makes this a collapsible group (timeline)
collapsed?: boolean // start the group collapsed
eventCreation?: boolean // false: no new or moved-in events on this row/column
background?: string // row (timeline) or column (time grid) background
cssClass?: string
[key: string]: unknown // role, avatar, capacity… anything you render
}Rows in the timeline
The timeline draws a row per resource in the order given. A vertical drag reassigns the event; dragBetweenResources={false} turns that off everywhere, and resourceEditable: false on an event or eventCreation: false on a resource turns it off case by case.
A crew for the week
Each row shows the person's role. Drag a session up or down to hand it to someone else.
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 ResourcesDemo() {
const hydrated = useHydrated()
const { events, handlers } = useEvents(studioSessions)
if (!hydrated) return <Placeholder height={520} />
return (
<ProScheduler
data={events}
resources={studioResources}
view={{ timeline: { type: "week", resolutionHorizontal: "day", dragTimeStep: 60 } }}
dragBetweenResources
renderResource={(resource) => (
<div className="flex min-w-0 items-center gap-2">
<span
className="size-2.5 shrink-0 rounded-full"
style={{ background: String(resource.color) }}
/>
<div className="min-w-0">
<div className="truncate text-sm font-medium">{resource.name}</div>
<div className="truncate text-xs text-muted-foreground">{String(resource.role)}</div>
</div>
</div>
)}
height={520}
{...handlers}
/>
)
}// 8 people. `renderResource` receives each object as passed,
// so custom fields such as `role` are there to render.
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"},
{"id":"dev","name":"Dev Patel","role":"Colourist","color":"#7c3aed"},
{"id":"elin","name":"Elin Berg","role":"Sound","color":"#db2777"},
{"id":"farah","name":"Farah Haddad","role":"Camera","color":"#0891b2"},
{"id":"gus","name":"Gus Almeida","role":"Motion","color":"#65a30d"},
{"id":"hana","name":"Hana Sato","role":"Designer","color":"#dc2626"}
]Columns in the time grid
resources: true on the time grid splits each day into a column per resource (only the leaves of a tree), with a second header row. Each column shows its resource’s events; drawing in a column books that resource, and dragging across columns reassigns.
<ProScheduler
data={appointments}
resources={doctors}
view={{
scheduler: {
type: "day",
resources: true, // a column per resource
groupBy: "date", // or "resource": the days under each resource
},
}}
/>Shared events
An array of resource ids makes one event belong to all of them. It renders once per resource, counts against each of them when overlaps are refused, and a drag moves only the copy you picked up.
// One meeting, three people: it shows in each of their rows or columns.
{ id: 7, title: "Kickoff", start, end, resource: ["ada", "ben", "chloe"] }
// Dragging Ben's copy onto Dev swaps just that one:
// resource: ["ada", "dev", "chloe"]Groups and hierarchy
Resources with children become collapsible groups in the timeline, nested as deep as you like. groupSummary shows each group’s descendants’ events on its own row, faded and read-only, so a collapsed group still shows how busy it is. The built-in editor lists only the leaves.
const resources = [
{
id: "post",
name: "Post-production",
eventCreation: false, // department rows are headings
children: [
{ id: "chloe", name: "Chloé Martin" },
{ id: "dev", name: "Dev Patel" },
],
},
{ id: "camera", name: "Camera", collapsed: true, children: [/* … */] },
]
<ProScheduler
resources={resources}
view={{ timeline: { type: "month", groupSummary: true } }}
onResourceCollapse={(group, collapsed) => save(group.id, collapsed)}
/>Row options, sidebars and footers
<ProScheduler
view={{ timeline: { type: "month", maxEventStack: 2, rowHeight: "equal" } }}
renderResourceHeader={() => "Crew"}
renderResource={(r) => <Person person={r} />}
renderSidebarHeader={() => "Revenue"}
renderSidebar={(r) => <Revenue of={r} />} // a right-hand column
renderDayFooter={({ date, events }) => events.length} // a cell under each day
renderResourceFooter={() => "Total"} // the bottom-left corner
styleConfig={{ resourceColWidth: 220, sidebarWidth: 140, footerHeight: 36 }}
/>| Option | Effect |
|---|---|
maxEventStack | Stacked events per row before a "+N more" chip per column |
rowHeight: "equal" | Every row as tall as the tallest |
groupSummary | Group rows show their descendants' events, faded |