ProSchedulerSign in

Timeline · Configuring the view

External navigation

refDate controls the visible month from outside; onSelectedDateChange keeps your state in step with the header.

Live demo

Use the outside buttons · Then the header's own arrows

Fullscreen
import { useState } from "react"
import { ProScheduler } from "@andreisaac/pro-scheduler"
import { studioAssignments, studioResources } from "./data/studio"
import { Choice, Toolbar, useEvents } from "./kit"

export function TimelineNavigationDemo() {
  const { events, handlers } = useEvents(studioAssignments)
  const [date, setDate] = useState(() => new Date())
  const shift = (months: number) => setDate(new Date(date.getFullYear(), date.getMonth() + months, 1))

  return (
    <div className="docs-demo__stack">
      <Toolbar label="Navigate">
        <Choice onClick={() => shift(-1)}>Previous month</Choice>
        <Choice onClick={() => setDate(new Date())}>Today</Choice>
        <Choice onClick={() => shift(1)}>Next month</Choice>
        <span className="demo-muted">
          Showing {date.toLocaleDateString([], { month: "long", year: "numeric" })}
        </span>
      </Toolbar>
      <ProScheduler
        data={events}
        resources={studioResources}
        view={{ timeline: { type: "month" } }}
        // Controlled from outside, and kept in step with the header's own arrows.
        refDate={date}
        onSelectedDateChange={setDate}
        height={520}
        {...handlers}
      />
    </div>
  )
}

About this demo

refDate controls the visible month from outside; onSelectedDateChange keeps your state in step with the header.

Things to try

  • Use the outside buttons
  • Then the header's own arrows

The props behind it are explained in API reference.

Use ProScheduler in your project