Skip to content
Haze UI

Video player

Native video with a themed control bar: seek, volume, speed, captions and fullscreen. Plain controls without script.

pnpm dlx shadcn@latest add @haze/video-player
Open preview in a new tab
Livesmall script

When to use

  • A product walkthrough or short tutorial clip hosted as a file you control
  • Media that needs captions, a visible seek bar and keyboard shortcuts in the site's own style
  • A recording embedded in docs or a changelog entry where autoplay would be rude

When not to use

  • Live streams, DRM or adaptive streaming need a dedicated player library.
  • A decorative looping background clip needs no controls; use a plain video element.
  • Audio-only content such as a podcast is better served by a native audio element.

Installation

Add the Haze registry to components.json once, then install Video player with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.

pnpm dlx shadcn@latest add @haze/video-player
First time? Registry and theme setup

1. Add to components.json:

{
  "registries": {
    "@haze": "http://localhost:4329/r/{name}.json"
  }
}

2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";

API reference

PropTypeDefaultDescription
id*string–Unique on the page. Becomes the id of the video element.
srcstring"/media/video-player/demo.mp4"URL of the video file (MP4 with H.264 plays everywhere).
posterstring–Image shown before the first play. Without one, the browser shows the first frame.
titlestring"Product walkthrough clip"Accessible name of the player region.
captions{ src: string; srclang: string; label: string } | nulldemo WebVTT fileWebVTT captions track. Pass null for none; the captions button is then omitted.
aspectstring"aspect-video"Tailwind aspect-ratio class for the picture area.
classstring–Extra classes on the player frame.

Keyboard interactions

SpaceK
Play or pause from the video or the seek slider
LeftRight (seek slider)
Jump back or forward 5 seconds
TabShiftTab
Move between play, mute, volume, speed, captions and fullscreen
EnterSpace (button)
Activate the focused control

Accessibility

  • Without script the browser's own controls stay on, so the video is fully usable. The script removes them and adds the themed bar.
  • The frame is a labelled region. The seek slider is a native range input with aria-valuetext such as "1:05 of 2:30".
  • Mute, captions and fullscreen are toggle buttons with aria-pressed; the play button changes its label between Play and Pause.
  • Speed, mute and captions changes are announced through a polite status region.
  • Nothing autoplays, with or without reduced-motion settings. Captions need a WebVTT track; transcripts for longer clips belong next to the player.

Notes for AI

Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.

  • Install and use

    Install the Haze UI component "Video player" with `npx shadcn@latest add @haze/video-player`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import VideoPlayer from "@/components/haze/ui/video-player.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/video-player.md

  • Customize with real content

    Adapt the Haze video-player ui for our product. Replace the demo values of these props with our real content: id, src, poster, title, captions, aspect, class. Keep the layout, the heading level rules and these accessibility details: Without script the browser's own controls stay on, so the video is fully usable. The script removes them and adds the themed bar. The frame is a labelled region. The seek slider is a native range input with aria-valuetext such as "1:05 of 2:30". Mute, captions and fullscreen are toggle buttons with aria-pressed; the play button changes its label between Play and Pause. Speed, mute and captions changes are announced through a polite status region. Nothing autoplays, with or without reduced-motion settings. Captions need a WebVTT track; transcripts for longer clips belong next to the player. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using video-player, check it fits: use it when a product walkthrough or short tutorial clip hosted as a file you control; media that needs captions, a visible seek bar and keyboard shortcuts in the site's own style; a recording embedded in docs or a changelog entry where autoplay would be rude. Avoid it when live streams, drm or adaptive streaming need a dedicated player library.; a decorative looping background clip needs no controls; use a plain video element.; audio-only content such as a podcast is better served by a native audio element.. Alternatives: @haze/aspect-ratio, @haze/story-viewer.

Dependencies

  • npm: @lucide/astro
  • @haze/utils
  • @haze/theme (one-time setup)

Source · Original Haze UI work.

Catalog

↑↓ moveEnter openEsc close

Keyboard shortcuts

CtrlK
Command palette
/
Focus search
←↑→↓
Move between cards
jk
Next / previous card
ci
Copy code / install command (detail page)
[]
Previous / next entry
?
This help
Esc
Close dialog