ProSchedulerSign in

Scheduler · Configuring the view

Custom range

type: "custom" with a range shows exactly those days — here starting today. The header arrows page by the range's own length.

Live demo

Switch between 2, 4 and 10 days · Page forward, then back

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

const today = () => {
  const d = new Date()
  return new Date(d.getFullYear(), d.getMonth(), d.getDate())
}

export function SchedulerCustomRangeDemo() {
  const { events, handlers } = useEvents(() => studioSessions())
  const [days, setDays] = useState(4)
  // Starts today; the arrows page by the range's own length.
  const range = useMemo(() => {
    const start = today()
    return { start, end: new Date(start.getFullYear(), start.getMonth(), start.getDate() + days) }
  }, [days])
  return (
    <>
      <Toolbar label="Days shown">
        {[2, 4, 10].map((n) => (
          <Choice key={n} active={days === n} onClick={() => setDays(n)}>
            {n} days
          </Choice>
        ))}
      </Toolbar>
      <ProScheduler
        data={events}
        resources={studioResources}
        view={{ scheduler: { type: "custom", range, startTime: "08:00", endTime: "19:00" } }}
        height={600}
        {...handlers}
      />
    </>
  )
}

About this demo

type: "custom" with a range shows exactly those days — here starting today. The header arrows page by the range's own length.

Things to try

  • Switch between 2, 4 and 10 days
  • Page forward, then back

The props behind it are explained in Scales, ranges and zoom.

Use ProScheduler in your project