Unified UI

Video Player

A styled video component with custom play/pause, mute, seek, and fullscreen controls, poster image, and keyboard shortcuts.

Basic

A styled video component with custom play/pause, mute, seek, and fullscreen controls, poster image, and keyboard shortcuts. Click the play button to interact.

0:00 / 0:00

Installation

Install the component via the CLI in one command.

npx @work-rjkashyap/unified-ui add video-player
pnpm dlx @work-rjkashyap/unified-ui add video-player
npx @work-rjkashyap/unified-ui add video-player
bunx @work-rjkashyap/unified-ui add video-player

If you haven't initialized your project yet, run npx @work-rjkashyap/unified-ui init first. See the CLI docs for details.

Or install the full package

Use this approach if you prefer to install the entire design system as a dependency instead of copying individual components.

npm install @work-rjkashyap/unified-ui
pnpm add @work-rjkashyap/unified-ui
yarn add @work-rjkashyap/unified-ui
bun add @work-rjkashyap/unified-ui

Anatomy

import {
	VideoPlayer,
	Button,
} from "@work-rjkashyap/unified-ui";

Examples

Default (16:9)

0:00 / 0:00

Aspect Ratios

video (16:9) — default

0:00 / 0:00

4/3

0:00 / 0:00

Autoplay, Loop & Muted

0:00 / 0:00

Without Controls

Without Poster

0:00 / 0:00

Muted by Default

0:00 / 0:00

onEnded Callback

0:00 / 0:00

Props

PropTypeDefaultDescription
srcstringVideo source URL.
posterstringPoster image URL.
aspectRatio"video" | "square" | "4/3" | "auto""video"Aspect ratio constraint.
autoPlaybooleanfalseAuto-play the video.
loopbooleanfalseLoop the video.
mutedbooleanfalseStart muted.
controlsbooleantrueShow custom controls overlay.
classNamestringAdditional CSS classes.
onEnded() => voidCallback when video finishes.

Keyboard Shortcuts

KeyAction
Space / KToggle play/pause
MToggle mute
FToggle fullscreen
Seek forward 5 seconds
Seek backward 5 seconds

Accessibility

  • Uses role="region" with aria-label="Video player".
  • All control buttons have descriptive aria-label attributes.
  • Fully keyboard navigable — all shortcuts work when the player is focused.
  • Big play button overlay when paused for clear affordance.
  • Time display and progress bar provide temporal orientation.
  • Focus ring visible on keyboard navigation via focus-visible.

Browsers require muted to be set for autoPlay to work without user interaction. Always pair autoPlay with muted for reliable behavior.


Design Tokens

TokenUsage
--borderPlayer container border
--radius-lgPlayer border radius
--backgroundControls gradient base
--foregroundControl icon colors
--primaryFocus ring color
--duration-fastControl transition speed

On this page