ProSchedulerSign in

Features

Time picker

Pick a start and end time on a single day by dragging a block: move it, stretch either edge, or draw a new one — with your other commitments shown behind it.

Usage

ProTimePicker is a one-day time grid holding a single range. It is controlled like the scheduler: it fires onChange when a gesture ends and renders whatever value you pass back. The header steps between days; changing day keeps the picked times. The scheduler's built-in event editor uses it for every timed event.

import { ProTimePicker } from "@andreisaac/pro-scheduler"

const [slot, setSlot] = useState({ start: new Date(2026, 9, 2, 14, 30), end: new Date(2026, 9, 2, 19, 0) })

<ProTimePicker
  value={slot}
  onChange={(value) => setSlot(value)}
  step={15}             // snap for drag, resize and keys (minutes)
  startTime="07:00"     // grid range; endTime may pass "24:00"
  endTime="22:00"
  height={480}
/>
What each gesture does
GestureResult
Drag the blockMoves the range, keeping its length
Drag the top or bottom gripChanges the start or the end
Drag on empty spaceDraws a new range
Click empty spaceMoves the range to start at that slot
↑ / ↓ (PgUp / PgDn) on the focused blockMoves by one step (four steps)
Shift + ↑ / ↓Shortens or lengthens the end by one step
Live demo

Book a slot

Drag the block or its grips. The team's sessions sit behind it, and overlaps are flagged.

import { useMemo, useState, useSyncExternalStore } from "react"
import { ProTimePicker, type PschBusyTime, type PschTimeRangeValue } from "@/components/pro-scheduler"
import { kindColors, studioSessions } from "@/lib/demo-data/studio"

const subscribe = () => () => {}

/** False during the server render and hydration, true afterwards. */
function useHydrated() {
  return useSyncExternalStore(subscribe, () => true, () => false)
}

function Placeholder({ height }: { height: number }) {
  return <div aria-hidden className="docs-demo__placeholder" style={{ height }} />
}

/** Today, 14:30 – 16:00: where the picker opens. */
function afternoonSlot(): PschTimeRangeValue {
  const today = new Date()
  const at = (h: number, m: number) =>
    new Date(today.getFullYear(), today.getMonth(), today.getDate(), h, m)
  return { start: at(14, 30), end: at(16, 0) }
}

export function TimePickerDemo() {
  const hydrated = useHydrated()
  const [slot, setSlot] = useState(afternoonSlot)
  const [conflicts, setConflicts] = useState<PschBusyTime[]>([])
  // The team's sessions show as busy time behind the selection.
  const busy = useMemo<PschBusyTime[]>(
    () => studioSessions().map((s) => ({ ...s, end: s.end!, color: kindColors[s.kind] })),
    []
  )
  if (!hydrated) return <Placeholder height={520} />

  return (
    <div className="docs-demo__stack">
      <ProTimePicker
        value={slot}
        busy={busy}
        step={15}
        height={480}
        className="mx-auto w-full max-w-sm"
        onChange={(value, info) => {
          setSlot(value)
          setConflicts(info.conflicts)
        }}
      />
      <ol className="docs-demo__log" aria-live="polite">
        <li>
          {slot.start.toLocaleString(undefined, { weekday: "short", day: "numeric", month: "short", hour: "2-digit", minute: "2-digit" })}
          {" – "}
          {slot.end.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit" })}
        </li>
        <li>{conflicts.length ? `Overlaps: ${conflicts.map((c) => c.title).join(", ")}` : "No conflicts"}</li>
      </ol>
    </div>
  )
}

Busy time and limits

busy draws existing commitments behind the selection, packed side by side when they overlap. When the range overlaps any of them the block is outlined and onChange reports them in conflicts — the picker never refuses a range, so you decide what a conflict means. minDuration and maxDuration bound the length while resizing and drawing.

<ProTimePicker
  value={slot}
  // Anything with a start and an end — your scheduler events work as-is.
  busy={events}
  minDuration={30}
  maxDuration={240}
  onChange={(value, { conflicts }) => {
    setSlot(value)
    setWarning(conflicts.length ? `Overlaps ${conflicts[0].title}` : null)
  }}
/>

Ranges longer than a day

A range that ends on a later day shows on its start day, running off the bottom of the grid with its end date noted there. Drag the start grip to change when it begins, or move the block to shift the whole range — its length is kept. The end has no grip on that day; set it from your own field (the built-in editor's End input). The header's day arrows move the whole range, keeping its length.

Starting empty

// Nothing picked yet: a click picks a defaultDuration-long range, a drag draws one.
<ProTimePicker value={null} defaultDuration={30} onChange={setSlot} />

// Uncontrolled
<ProTimePicker defaultValue={{ start, end }} onChange={save} />