ProSchedulerSign in

Scheduler · Templating

Cell content

renderCell draws inside every empty cell under the events: a studio's hourly rate, dearer in the evening and at weekends.

Live demo

Compare a weekday morning with Saturday · Draw a booking to see its price in the title

Fullscreen
import { ProScheduler, type PschCellData, type SchedulerEvent } from "@andreisaac/pro-scheduler"
import { useEvents } from "./kit"

/** Peak slots cost more; the price shows in every free half-hour. */
function priceAt(date: Date) {
  const hour = date.getHours()
  const weekend = date.getDay() === 0 || date.getDay() === 6
  if (weekend) return 70
  return hour >= 17 || hour < 9 ? 55 : 40
}

export function CellContentDemo() {
  const { events, handlers } = useEvents<SchedulerEvent>([])

  return (
    <ProScheduler
      data={events}
      view={{ scheduler: { type: "week", startTime: "07:00", endTime: "21:00", timeCellStep: 30, dragTimeStep: 30 } }}
      // Drawn under the events, once per visible cell.
      renderCell={({ date }: PschCellData) => (
        <span className="absolute right-1 bottom-0.5 text-[10px] text-muted-foreground tabular-nums">
          €{priceAt(date)}
        </span>
      )}
      extendDefaultEvent={({ start }) => ({ title: `Studio hire · €${priceAt(start)}/30 min` })}
      height={600}
      {...handlers}
    />
  )
}

About this demo

renderCell draws inside every empty cell under the events: a studio's hourly rate, dearer in the evening and at weekends.

Things to try

  • Compare a weekday morning with Saturday
  • Draw a booking to see its price in the title

The props behind it are explained in Custom rendering.

Use ProScheduler in your project