ProSchedulerSign in

Scheduler · Configuring the view

Grid lines, cells and cursor time

Toggle which grid lines draw, the cell size, a time readout that follows the pointer, and fitting the day to the height.

Live demo

Hover the grid with cursor time on · Switch to 15-minute cells · Fit to height

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 GridOptionsDemo() {
  const { events, handlers } = useEvents(studioSessions)
  const [gridLines, setGridLines] = useState<"both" | "horizontal" | "vertical" | "none">("both")
  const [cellStep, setCellStep] = useState(30)
  const [cursorTime, setCursorTime] = useState(true)
  const [fitToHeight, setFitToHeight] = useState(false)

  return (
    <div className="docs-demo__stack">
      <Toolbar label="Grid options">
        <Field label="Lines">
          <select value={gridLines} onChange={(e) => setGridLines(e.target.value as typeof gridLines)}>
            <option value="both">Both</option>
            <option value="horizontal">Horizontal</option>
            <option value="vertical">Vertical</option>
            <option value="none">None</option>
          </select>
        </Field>
        <Field label="Cell">
          <select value={cellStep} onChange={(e) => setCellStep(Number(e.target.value))}>
            {[15, 30, 60].map((m) => (
              <option key={m} value={m}>
                {m} min
              </option>
            ))}
          </select>
        </Field>
        <Choice active={cursorTime} onClick={() => setCursorTime(!cursorTime)}>
          Cursor time
        </Choice>
        <Choice active={fitToHeight} onClick={() => setFitToHeight(!fitToHeight)}>
          Fit to height
        </Choice>
      </Toolbar>
      <ProScheduler
        data={events}
        resources={studioResources}
        view={{
          scheduler: {
            type: "week",
            startTime: "07:00",
            endTime: "20:00",
            gridLines,
            timeCellStep: cellStep,
            cursorTime,
            fitToHeight,
          },
        }}
        height={560}
        {...handlers}
      />
    </div>
  )
}

About this demo

Toggle which grid lines draw, the cell size, a time readout that follows the pointer, and fitting the day to the height.

Things to try

  • Hover the grid with cursor time on
  • Switch to 15-minute cells
  • Fit to height

The props behind it are explained in Views.

Use ProScheduler in your project