ProSchedulerSign in

Timeline · Templating

Header and footer template

renderDayFooter adds a cell under every day — here how many people are booked, in red from five — and renderResourceFooter the corner total.

Live demo

Move work onto a busy day and watch its count

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

const days = (e: SchedulerEvent) =>
  (new Date(e.end!).getTime() - new Date(e.start).getTime()) / 86_400_000

export function HeaderFooterDemo() {
  const { events, handlers } = useEvents(studioAssignments)
  const total = events.reduce((sum, e) => sum + days(e), 0)

  return (
    <ProScheduler
      data={events}
      resources={studioResources}
      view={{ timeline: { type: "month" } }}
      // A cell under every day, and a corner under the resource column.
      renderDayFooter={({ events: onDay }) => (
        <span className={onDay.length >= 5 ? "font-semibold text-destructive" : "text-muted-foreground"}>
          {onDay.length || ""}
        </span>
      )}
      renderResourceFooter={() => <span>{Math.round(total)} person-days</span>}
      height={560}
      {...handlers}
    />
  )
}

About this demo

renderDayFooter adds a cell under every day — here how many people are booked, in red from five — and renderResourceFooter the corner total.

Things to try

  • Move work onto a busy day and watch its count

The props behind it are explained in Custom rendering.

Use ProScheduler in your project