ProSchedulerSign in

Timeline · Configuring the view

Event search

Search narrows the bars; a result click navigates the timeline to it.

Live demo

Search for “Harbor” · Click a result

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

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

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

  return (
    <div className="demo-split">
      <aside className="demo-side">
        <input
          type="search"
          placeholder="Search assignments"
          value={query}
          onChange={(e) => setQuery(e.target.value)}
          aria-label="Search assignments"
        />
        <ul>
          {matches.map((event) => (
            <li key={event.id}>
              <button type="button" onClick={() => scheduler.current?.navigateToEvent(event)}>
                <strong>{event.title}</strong>
                <span>{when(event.start)}</span>
              </button>
            </li>
          ))}
          {query && matches.length === 0 && <li className="demo-muted">No matches</li>}
        </ul>
      </aside>
      <ProScheduler
        ref={scheduler}
        data={query.trim() ? matches : events}
        resources={studioResources}
        view={{ timeline: { type: "month" } }}
        height={520}
        {...handlers}
      />
    </div>
  )
}

About this demo

Search narrows the bars; a result click navigates the timeline to it.

Things to try

  • Search for “Harbor”
  • Click a result

The props behind it are explained in API reference.

Use ProScheduler in your project