Video Player

PreviousNext

Embed YouTube videos and play HTML5 videos with customizable controls and full accessibility support

Embed YouTube videos with proper styling and responsive design, or use the composable HTML5 video player built on media-chrome for direct video files. Supports full keyboard navigation, screen reader accessibility, and seamless integration with shadcn/ui theming.

For YouTube videos, use an iframe embed with responsive aspect ratio and proper styling. This is the recommended approach for most use cases as it leverages YouTube's CDN and built-in features.

Common YouTube URL parameters:

  • autoplay=1 - Start playing automatically (must be muted)
  • mute=1 - Mute the video
  • loop=1 - Loop the video
  • controls=0 - Hide player controls
  • modestbranding=1 - Minimal YouTube branding
  • start=10 - Start at 10 seconds
  • end=60 - End at 60 seconds

HTML5 Video Player

For direct video files (MP4, WebM, OGG), use the VideoPlayer component with custom controls.

Basic HTML5 Player

A simple video player with essential controls: play button, progress bar, and time display.

HTML5 Full Controls

All available controls including seek buttons, volume controls, and mute button.

Component API (HTML5 Video Player)

VideoPlayer

The main wrapper component that provides context for all child components.

PropTypeDescription
classNamestringCustom CSS classes
styleCSSPropertiesCustom inline styles
childrenReactNodeChild components (VideoPlayerContent and VideoPlayerControlBar)

VideoPlayerContent

The video element that displays the media content.

PropTypeDefaultDescription
srcstring-Video source URL
slotstring-Should be set to "media" for media-chrome integration
autoPlaybooleanfalseStart playing automatically
loopbooleanfalseLoop the video
mutedbooleanfalseMute the audio
preload"none" | "metadata" | "auto""metadata"Preload strategy
controlsbooleanfalseShow native browser controls (not recommended when using custom controls)
posterstring-Image to show before video plays
crossOrigin"anonymous" | "use-credentials" | ""-CORS setting for cross-origin videos
classNamestring-Custom CSS classes

VideoPlayerControlBar

Container for player controls.

PropTypeDescription
classNamestringCustom CSS classes
childrenReactNodeControl components

VideoPlayerPlayButton

Play/Pause toggle button.

PropTypeDescription
classNamestringCustom CSS classes

VideoPlayerSeekBackwardButton

Button to seek backward by a set interval (default 10 seconds).

PropTypeDescription
classNamestringCustom CSS classes
seekOffsetnumberSeconds to seek backward

VideoPlayerSeekForwardButton

Button to seek forward by a set interval (default 10 seconds).

PropTypeDescription
classNamestringCustom CSS classes
seekOffsetnumberSeconds to seek forward

VideoPlayerTimeRange

Interactive progress bar for seeking through the video.

PropTypeDescription
classNamestringCustom CSS classes

VideoPlayerTimeDisplay

Displays current time and optionally total duration.

PropTypeDescription
classNamestringCustom CSS classes
showDurationbooleanShow total duration alongside current time

VideoPlayerMuteButton

Mute/Unmute toggle button.

PropTypeDescription
classNamestringCustom CSS classes

VideoPlayerVolumeRange

Interactive volume slider.

PropTypeDescription
classNamestringCustom CSS classes