ProSchedulerSign in

Scheduler · Configuring the view

Event search sidebar

Search filters what the grid shows; clicking a result navigates to it through the ref handle.

Live demo

Search for “review” · Click a result in another week

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

export function EventSearchDemo() {
  const { events, handlers } = useEvents(studioSessions)
  const [query, setQuery] = useState("")
  const scheduler = useRef<ProSchedulerInstance>(null)

  const matches = useMemo(() => {
    const q = query.trim().toLowerCase()
    if (!q) return []
    return events.filter((e) => `${e.title} ${e.client} ${e.kind}`.toLowerCase().includes(q))
  }, [events, query])

  return (
    <div className="demo-split">
      <aside className="demo-side">
        <input
          type="search"
          placeholder="Search title, client or kind"
          value={query}
          onChange={(e) => setQuery(e.target.value)}
          aria-label="Search events"
        />
        <ul>
          {matches.map((event) => (
            <li key={event.id}>
              <button type="button" onClick={() => scheduler.current?.navigateToEvent(event)}>
                <strong>{event.title}</strong>
                <span>
                  {event.client} · {when(event.start)}
                </span>
              </button>
            </li>
          ))}
          {query && matches.length === 0 && <li className="demo-muted">No matches</li>}
        </ul>
      </aside>
      <ProScheduler
        ref={scheduler}
        // While searching, the grid shows only the matches.
        data={query.trim() ? matches : events}
        resources={studioResources}
        view={{ scheduler: { type: "week", startTime: "07:00", endTime: "20:00" } }}
        height={560}
        {...handlers}
      />
    </div>
  )
}

About this demo

Search filters what the grid shows; clicking a result navigates to it through the ref handle.

Things to try

  • Search for “review”
  • Click a result in another week

The props behind it are explained in API reference.

Use ProScheduler in your project