ProSchedulerSign in

Agenda · Templating

Custom event content

renderEventContent lays out each row: a colour bar, start and end, the client and person, and a kind badge.

Live demo

Read a row's badge · Open a row

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

export function AgendaEventContentDemo() {
  const { events, handlers } = useEvents(studioSessions)

  return (
    <ProScheduler
      data={events}
      resources={studioResources}
      view={{ agenda: { type: "week", size: 2 } }}
      renderEventContent={({ original, start, end, color }) => {
        const event = original as StudioEvent
        const person = studioResources.find((r) => r.id === event.resource)
        return (
          <div className="flex w-full items-center gap-3">
            <span className="h-9 w-1 shrink-0 rounded-full" style={{ background: color }} />
            <div className="w-24 shrink-0 text-xs text-muted-foreground tabular-nums">
              {start.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })}
              <br />
              {end.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })}
            </div>
            <div className="min-w-0 flex-1">
              <div className="truncate text-sm font-medium">{event.title}</div>
              <div className="truncate text-xs text-muted-foreground">
                {event.client} · {person?.name}
              </div>
            </div>
            <span
              className="rounded-full px-2 py-0.5 text-[11px] font-medium text-white"
              style={{ background: kindColors[event.kind] }}
            >
              {event.kind}
            </span>
          </div>
        )
      }}
      height={560}
      {...handlers}
    />
  )
}

About this demo

renderEventContent lays out each row: a colour bar, start and end, the client and person, and a kind badge.

Things to try

  • Read a row's badge
  • Open a row

The props behind it are explained in Custom rendering.

Use ProScheduler in your project