ProSchedulerSign in

Timeline · Templating

Custom event tooltip

A hover card with the client, the dates and the length in days.

Live demo

Hover a bar

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

const day = (base: Date, n: number) => new Date(base.getFullYear(), base.getMonth(), base.getDate() + n)

export function TimelineTooltipDemo() {
  const { events, handlers } = useEvents(studioAssignments)

  return (
    <ProScheduler
      data={events}
      resources={studioResources}
      view={{ timeline: { type: "month" } }}
      renderEventTooltip={({ original, start, end }) => {
        const event = original as StudioEvent
        const days = Math.round((end.getTime() - start.getTime()) / 86_400_000)
        return (
          <div className="grid gap-1 py-0.5">
            <strong>{event.client}</strong>
            <span>
              {start.toLocaleDateString([], { day: "numeric", month: "short" })} –{" "}
              {end.toLocaleDateString([], { day: "numeric", month: "short" })} · {days} days
            </span>
            <span className="rounded px-1.5 text-[10px] text-white" style={{ background: kindColors[event.kind], width: "fit-content" }}>
              {event.kind}
            </span>
          </div>
        )
      }}
      height={520}
      {...handlers}
    />
  )
}

About this demo

A hover card with the client, the dates and the length in days.

Things to try

  • Hover a bar

The props behind it are explained in Custom rendering.

Use ProScheduler in your project