ProSchedulerSign in

Features

Custom rendering

Replace what is inside an event, the whole event, the day headers, the resource cells or the header bar — keeping the drag, resize and layout behaviour underneath.

Event content

renderEventContent replaces the inside of every event and keeps the default chrome — colour, rounded block, resize handles, drag. It receives the event data: your event as original, normalized start and end dates, the resolved color, and isMultiDay.

<ProScheduler
  renderEventContent={({ original, start, end, color, isMultiDay }) => (
    <div className="grid gap-0.5 text-xs">
      <strong>{original.title}</strong>
      <span>{original.client}</span>
    </div>
  )}
  …
/>
Event renderers
PropReplacesScope
renderEventContentThe inside of the eventEvery view
renderEventThe whole event elementEvery view
renderTimelineEventThe whole event elementTimeline only; wins over renderEvent
renderSchedulerEventThe whole event elementTime grid only
renderAgendaEventThe whole list itemAgenda only
Live demo

Coloured by kind, with the client inside

Events carry the client and time; the header is rebuilt from the building blocks.

import { useMemo, useState, useSyncExternalStore } from "react"
import { CalendarNav, CalendarNext, CalendarPrev, CalendarToday, ProScheduler, type SchedulerEvent } from "@/components/pro-scheduler"
import { kindColors, studioResources, studioSessions, type StudioEvent } 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 CustomRenderingDemo() {
  const hydrated = useHydrated()
  const { events, handlers } = useEvents(() =>
    // Colour by kind of work rather than by person.
    studioSessions().map((event) => ({ ...event, color: kindColors[event.kind] }))
  )
  if (!hydrated) return <Placeholder height={600} />

  return (
    <ProScheduler
      data={events}
      resources={studioResources}
      view={{ scheduler: { type: "week", startTime: "07:00", endTime: "19:00" } }}
      height={600}
      renderHeader={() => (
        <div className="flex items-center justify-between gap-2 border-b border-border px-3 py-2">
          <div className="flex items-center gap-1">
            <CalendarPrev />
            <CalendarToday />
            <CalendarNext />
          </div>
          <CalendarNav />
          <span className="text-xs text-muted-foreground">{events.length} bookings</span>
        </div>
      )}
      renderEventContent={({ original, start }) => {
        const event = original as StudioEvent
        return (
          <div className="grid gap-0.5 text-xs leading-tight">
            <strong className="truncate">{event.title}</strong>
            <span className="truncate opacity-85">{event.client}</span>
            <span className="opacity-70">
              {start.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit" })} · {event.kind}
            </span>
          </div>
        )
      }}
      {...handlers}
    />
  )
}

renderHeader replaces the whole navigation bar. Compose it from the same blocks the default uses — they read the scheduler’s state from context, so they need no props — or read useScheduler() for the title, the active view and the navigation functions and build something entirely your own.

import {
  CalendarNav, CalendarPrev, CalendarNext, CalendarToday,
  ViewSwitcher, ViewLengthSelect, useScheduler,
} from "@andreisaac/pro-scheduler"

function Toolbar() {
  const { title, activeType } = useScheduler()
  return (
    <div className="flex items-center justify-between border-b px-3 py-2">
      <div className="flex gap-1">
        <CalendarPrev /><CalendarToday /><CalendarNext />
      </div>
      <CalendarNav />
      <div className="flex gap-2">
        <ViewLengthSelect />
        <ViewSwitcher />
      </div>
    </div>
  )
}

<ProScheduler renderHeader={() => <Toolbar />} … />

Day and column headers

renderDay replaces each day heading in the time grid and the timeline, and the content of each day cell in the calendar. renderHour, renderWeek, renderMonth and renderYear are accepted as aliases.

<ProScheduler
  renderDay={({ date }) => (
    <div className="text-center">
      <div className="text-xs uppercase">{date.toLocaleDateString(undefined, { weekday: "short" })}</div>
      <div className="font-semibold">{date.getDate()}</div>
    </div>
  )}
  …
/>