Vertical scrollbar preview
Track-stack scroll controls wired to scrollTop.
Installation
pnpm add @techsquidtv/canvas-timeline-reactnpm install @techsquidtv/canvas-timeline-reactyarn add @techsquidtv/canvas-timeline-reactbun add @techsquidtv/canvas-timeline-react- 1
Install the package.
The command above adds the React bindings and their package dependencies.
- 2
Import from the React entrypoint.
@techsquidtv/canvas-timeline-react - 3
Add the timeline styles.
Use the full stylesheet with shadcn-compatible tokens, or base.css when your app owns the visual theme.
Default visuals import '@techsquidtv/canvas-timeline-react/styles.css';Base geometry import '@techsquidtv/canvas-timeline-react/base.css';
Usage
import { useMemo } from 'react';import { TimelineEngine } from '@techsquidtv/canvas-timeline-core';import { Timeline, TimelineProvider } from '@techsquidtv/canvas-timeline-react';
const tracks = Array.from({ length: 8 }, (_, index) => ({ id: `track-${index + 1}`, kind: 'visual', clips: [], selected: false, locked: false, muted: false, visible: true,}));
export function TimelineVerticalScrollbar() { const engine = useMemo(() => new TimelineEngine({ tracks }), []);
return ( <TimelineProvider engine={engine}> <div className="grid h-80 grid-cols-[minmax(0,1fr)_auto]"> <Timeline.Root> <Timeline.TrackList> {tracks.map((track) => ( <Timeline.Track key={track.id} trackId={track.id} /> ))} </Timeline.TrackList> </Timeline.Root>
<Timeline.VerticalScrollbar> <Timeline.VerticalScrollbarThumb> <Timeline.VerticalScrollbarHandle side="start" /> <Timeline.VerticalScrollbarHandle side="end" /> </Timeline.VerticalScrollbarThumb> </Timeline.VerticalScrollbar> </div> </TimelineProvider> );}Notes
- Render these components inside a
TimelineProviderso they can read the sharedTimelineEngine. - Import
@techsquidtv/canvas-timeline-react/styles.csswhen your app defines shadcn-compatible semantic tokens, orbase.csswhen supplying your own theme. - CSS styles interaction layers; renderer theme styles canvas-painted timeline visuals.
- Use the theming guide when CSS tokens should drive canvas-painted colors.
- The vertical scrollbar reads viewportHeight, maxScrollTop, and scrollTop from the shared TimelineEngine.
- Dragging the thumb pans with engine.setScrollTop(); dragging either handle scales expanded track heights for vertical zoom.
- Mount Timeline.Root in the same TimelineProvider so the engine knows the measured viewport height used for vertical scroll bounds.
- Use Timeline.ViewportScrollbar for horizontal time panning and time zoom; use VerticalScrollbar for track-stack panning and row-height zoom.
API Reference
Vertical Scrollbar
A timeline adapter that maps range scrollbar changes to vertical track scrolling.
Exports
| Name | Reference | Description |
|---|---|---|
Timeline.VerticalScrollbar | API reference | Timeline-aware root that adapts the generic range scrollbar to scrollTop. |
Timeline.VerticalScrollbarThumb | API reference | Draggable thumb representing the visible track stack. |
Timeline.VerticalScrollbarHandle | API reference | Range handle for custom vertical range compositions. |
useTimelineVerticalScrollbar | API reference | Hook that derives range scrollbar props from vertical timeline viewport state. |
useTimelineVerticalRangeControl | API reference | Adds formatted ARIA values to the vertical scrollbar adapter. |
useTimelineScrollTop | API reference | Subscribes directly to live vertical scroll offset changes. |