ProSchedulerSign in

Scheduler · Configuring the view

External date navigation

Drive the visible date from your own controls through the selectedDate prop, and hear about the scheduler's own navigation through onSelectedDateChange.

Live demo

Pick a date in the date input · Use the scheduler's own arrows and watch the input follow

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

export function ExternalNavigationDemo() {
  const { events, handlers } = useEvents(studioSessions)
  const [date, setDate] = useState(() => new Date())
  const iso = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`

  return (
    <div className="docs-demo__stack">
      <Toolbar label="Navigate">
        <Choice onClick={() => setDate(new Date(date.getFullYear(), date.getMonth(), date.getDate() - 7))}>
          Previous week
        </Choice>
        <Choice onClick={() => setDate(new Date())}>This week</Choice>
        <Choice onClick={() => setDate(new Date(date.getFullYear(), date.getMonth(), date.getDate() + 7))}>
          Next week
        </Choice>
        <Field label="Go to">
          <input
            type="date"
            value={iso}
            onChange={(e) => {
              const [y, m, d] = e.target.value.split("-").map(Number)
              if (y) setDate(new Date(y, m - 1, d))
            }}
          />
        </Field>
      </Toolbar>
      <ProScheduler
        data={events}
        resources={studioResources}
        // Controlled: the page follows `selectedDate`, and reports the
        // scheduler's own navigation back so both stay in step.
        selectedDate={date}
        onSelectedDateChange={setDate}
        view={{ scheduler: { type: "week", startTime: "07:00", endTime: "20:00" } }}
        height={560}
        {...handlers}
      />
    </div>
  )
}

About this demo

Drive the visible date from your own controls through the selectedDate prop, and hear about the scheduler's own navigation through onSelectedDateChange.

Things to try

  • Pick a date in the date input
  • Use the scheduler's own arrows and watch the input follow

The props behind it are explained in API reference.

Use ProScheduler in your project