# Scroll Video

> A video that plays frame by frame as you scroll through a pinned stage, with lines of copy that take turns over it.

```tsx
import { ScrollVideo } from '@brand-studio/ui';

export default function ScrollVideoDemo() {
  return (
    <div style={{ width: '100%' }}>
      <ScrollVideo label="The Halden R turning, then coming apart into its parts" src="/videos/halden-turn.mp4" poster="/videos/halden-turn.jpg" length={320} steps={[
        { at: 0, text: 'One body, milled from brass.' },
        { at: .35, text: 'A grip that finds your hand.' },
        { at: .72, text: 'Seven parts. Every one replaceable.' },
      ]} />
    </div>
  );
}
```

## Installation

```sh
npm install @brand-studio/ui
```

React 18 or 19 is a peer dependency. Import the stylesheet once and wrap the app in a brand theme:

```tsx
import '@brand-studio/ui/styles.css';
import { BrandTheme, ScrollVideo } from '@brand-studio/ui';
import brand from './brand.json';

<BrandTheme palette={brand.tokens} mode="system">
  {/* your app */}
</BrandTheme>
```

## Usage

```tsx
import { ScrollVideo } from '@brand-studio/ui';
```

```tsx
<ScrollVideo label="The Halden R turning, then coming apart" src="/turn.mp4" poster="/turn.jpg" length={320} steps={[
  { at: 0, text: 'One body, milled from brass.' },
  { at: .72, text: 'Seven parts. Every one replaceable.' },
]} />
```

`length` is the scroll distance in viewport heights. Each step shows from its `at` point, between 0 and 1, until the next one. Encode the video with a keyframe on every frame so it seeks without stalling:

```sh
ffmpeg -i turn.mov -c:v libx264 -crf 27 -g 1 -movflags +faststart -an turn.mp4
```

## Accessibility

- The section is labelled, and so is the video; describe what it shows in `label`.
- Before scripts run, and under reduced motion, it is an ordinary muted video with controls and the steps as a list.
- The steps are real text over the video; keep them short and check their contrast against every frame.

## API Reference

| Prop | Type | Default |
|---|---|---|
| `src` | `string` | – |
| `poster?` | `string` | – |
| `label` | `string` | – |
| `steps?` | `ScrollVideoStep[]` | – |
| `length?` | `number` | `300` |
| `className?` | `string` | `''` |

Source: https://brandstudio.js.org/docs/components/scroll-video/
