A muted looping video next to a list of steps. The current step is highlighted from the video's currentTime, a progress bar runs inside it, and a click on any step seeks the video there. Works well for short how-to clips. It is a client component with no dependencies: JavaScript reads the video time and writes the progress into one CSS variable, the rest is styling.
Preview
Click a step to jump to it.
Installation
Usage
import { VideoSyncedSteps } from "@/components/ui/video-synced-steps"
const steps = [
{ title: "Open the editor", description: "Pick a project.", start: 0 },
{ title: "Choose a template", start: 3.5 },
{ title: "Adjust the details", start: 7 },
{ title: "Publish", start: 10.5 },
]
export default function Example() {
return (
<VideoSyncedSteps
src="/videos/how-to.mp4"
poster="/videos/how-to-poster.jpg"
steps={steps}
/>
)
}Examples
Stacked layout
layout="stack" puts the video above the list. Handy for narrow columns and wide videos.
<VideoSyncedSteps
src="/videos/how-to.mp4"
steps={steps}
layout="stack"
className="max-w-sm"
/>Paused start and step events
autoPlay={false} waits for the user. onStepChange reports the active step, for example to sync other UI.
Starts paused. Press play or pick a step.
Current step: 1
const [index, setIndex] = useState(0)
<VideoSyncedSteps
src="/videos/how-to.mp4"
steps={steps}
autoPlay={false}
onStepChange={setIndex}
labels={{ play: "Play", pause: "Pause", steps: "How it works" }}
/>
<p>Current step: {index + 1}</p>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| src | string | - | Video URL |
| poster | string | - | Poster shown before the video loads |
| steps | { title: ReactNode; description?: ReactNode; start: number }[] | - | Steps: title, optional description and start second |
| layout | "side" | "stack" | "side" | Video next to the list or above it |
| autoPlay | boolean | true | Play automatically while the block is on screen |
| videoClassName | string | - | Classes for the video element, e.g. aspect ratio |
| labels | { play?: string; pause?: string; steps?: string } | - | Texts for the play button and the list name |
| onStepChange | (index: number) => void | - | Called with the index of the new active step |
| className | string | - | Additional CSS classes |
Features
- Synced by time: the active step is taken from currentTime on every frame while playing
- Seek on click: every step is a button that rewinds the video to its start
- Pauses off screen: an IntersectionObserver stops the video when it scrolls away
- Pause button: the user can stop the motion; with reduced motion the video starts paused