ProSchedulerSign in

Timeline · Templating

Event appearance

renderTimelineEvent draws the whole bar: an outlined pill with the kind and client.

Live demo

Drag a pill · Stretch one

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

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

  return (
    <ProScheduler
      data={events}
      resources={studioResources}
      view={{ timeline: { type: "month" } }}
      styleConfig={{ laneHeight: 44 }}
      // The whole bar is custom; drag and resize still work around it.
      renderTimelineEvent={({ original, start, end }) => {
        const event = original as StudioEvent
        const days = Math.max(1, Math.round((end.getTime() - start.getTime()) / 86_400_000))
        return (
          <div
            className="flex h-full items-center gap-2 overflow-hidden rounded-full border-2 bg-card px-2 text-xs shadow-xs"
            style={{ borderColor: kindColors[event.kind] }}
          >
            <span
              className="shrink-0 rounded-full px-1.5 py-0.5 text-[10px] font-semibold text-white"
              style={{ background: kindColors[event.kind] }}
            >
              {event.kind}
            </span>
            <span className="truncate font-medium text-foreground">{event.client}</span>
            <span className="ml-auto shrink-0 text-muted-foreground">{days}d</span>
          </div>
        )
      }}
      height={600}
      {...handlers}
    />
  )
}

About this demo

renderTimelineEvent draws the whole bar: an outlined pill with the kind and client.

Things to try

  • Drag a pill
  • Stretch one

The props behind it are explained in Custom rendering.

Use ProScheduler in your project