nook
Browse the docs

Components

Video Player

Native

A video with its own controls: play, seek, time, mute and full screen.

See the prompt
0:00 / 0:00

Installation

npx nook-ui@latest add video-player

Prompt

Paste this into your AI coding assistant. It adds this exact component, the same way the CLI does, and tells the assistant how to use it.

Short. For assistants that can run commands in your project.

Plain text
Add the Nook "Video Player" component to this project, exactly as Nook ships it.

A video with its own controls: play, seek, time, mute and full screen.

Steps
1. Check for `nook.json` in the project root. If it is missing, run `npx nook-ui@latest init` first (React or Next.js with Tailwind CSS v4). It adds the Nook tokens, the theme and `cn()`.
2. Run `npx nook-ui@latest add video-player`. It writes `components/ui/video-player.tsx` together with everything the component needs. Do not write the component from memory.
3. If you cannot run commands, fetch http://localhost:3000/r/video-player.json, write every entry of `files` to the path it names, install the packages in `dependencies`, and repeat for each name in `registryDependencies`.
4. Use it where I ask. Start from this example:

```tsx
import { VideoPlayer } from "@/components/ui/video-player";

export default function VideoPlayerDefault() {
  return <VideoPlayer className="max-w-lg" title="Product tour" src="/examples/clip.mp4" poster="/examples/clip.jpg" />;
}
```

API
- `VideoPlayer`: The player. Also accepts everything a `video` element does, such as `src` and `poster`.
  - `title` (`string`): Names the player for assistive tech.
  - `ratio` (`number`, default 16 / 9): Width divided by height.

Rules
- Colors, radii, shadows and motion come from Nook tokens and classes such as `bg-primary`, `text-muted-foreground`, `border-border`, `rounded-lg` and `h-control`. Never hard-code them.
- Do not restyle or simplify the file. Change how it looks through `className`, its props and the theme.
- It must keep working with the keyboard, in light and dark mode, and in the sharp, soft and bold styles.
- Accessibility: Focus the player and use Space or K to play, the arrow keys to skip five seconds and M to mute. Pass a captions track as children whenever the video has speech.

Done when the component renders like the example in light and dark mode and the project type-checks.

Usage

import { VideoPlayer } from "@/components/ui/video-player";

export default function VideoPlayerDefault() {
  return <VideoPlayer className="max-w-lg" title="Product tour" src="/examples/clip.mp4" poster="/examples/clip.jpg" />;
}

Examples

Square video

0:00 / 0:00

Wide video

0:00 / 0:00

No source

0:00 / 0:00

Props

VideoPlayer

The player. Also accepts everything a `video` element does, such as `src` and `poster`.

PropTypeDefaultDescription
titlestring–Names the player for assistive tech.
rationumber16 / 9Width divided by height.

Accessibility

Focus the player and use Space or K to play, the arrow keys to skip five seconds and M to mute. Pass a captions track as children whenever the video has speech.

Checked against WCAG 2.1 AA with automated axe tests and keyboard tests on every release.