ProSchedulerSign in

Scheduler · Templating

Custom event rendering

renderEventContent fills each block with your markup — client, times and person here — while colour, dragging and resizing keep working.

Live demo

Read the client line inside a block · Resize one and watch the times update

Fullscreen
import { ProScheduler } from "@andreisaac/pro-scheduler"
import { kindColors, studioResources, studioSessions, type StudioEvent } from "./data/studio"
import { useEvents } from "./kit"

export function CustomEventDemo() {
  const { events, handlers } = useEvents(() =>
    studioSessions().map((event) => ({ ...event, color: kindColors[event.kind] }))
  )

  return (
    <ProScheduler
      data={events}
      resources={studioResources}
      view={{ scheduler: { type: "week", startTime: "07:00", endTime: "20:00" } }}
      renderEventContent={({ original, start, end }) => {
        const event = original as StudioEvent
        const person = studioResources.find((r) => r.id === event.resource)
        return (
          <div className="grid gap-0.5 text-[11px] leading-tight">
            <strong className="truncate">{event.title}</strong>
            <span className="truncate opacity-90">{event.client}</span>
            <span className="truncate opacity-75">
              {start.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })}–
              {end.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })} · {person?.name}
            </span>
          </div>
        )
      }}
      height={620}
      {...handlers}
    />
  )
}

About this demo

renderEventContent fills each block with your markup — client, times and person here — while colour, dragging and resizing keep working.

Things to try

  • Read the client line inside a block
  • Resize one and watch the times update

The props behind it are explained in Custom rendering.

Use ProScheduler in your project