Docs
Hover Video Player

Hover Video Player

A video player component that plays on hover with advanced features like mobile support, picture-in-picture, and custom overlays.

Installation

npx shadcn@latest add https://cult-ui.com/r/hover-video-player.json

Usage

import { HoverVideoPlayer } from "@/components/ui/hover-video-player"
export default function Example() {
  return (
    <HoverVideoPlayer
      videoSrc="/demo-video.mp4"
      thumbnailSrc="/demo-thumbnail.jpg"
    />
  )
}

Props

PropTypeDefaultDescription
videoSrcstringrequiredURL of the video to play
thumbnailSrcstring-URL of the thumbnail image
hoverOverlayReactNode-Custom overlay shown while hovering
pausedOverlayReactNode-Custom overlay shown when paused
loadingOverlayReactNode-Custom overlay shown while loading
playbackStartDelaynumber0Delay before playing video on hover (ms)
restartOnPausedbooleanfalseReset video position when paused
enableControlsbooleanfalseShow playback controls
mutedbooleantrueStart video muted
loopbooleantrueLoop video playback
cropTopnumber0Percentage to crop from top
cropBottomnumber0Percentage to crop from bottom

Examples

Basic Player

<HoverVideoPlayer
  videoSrc="/demo-video.mp4"
  thumbnailSrc="/demo-thumbnail.jpg"
/>

With Controls

<HoverVideoPlayer
  videoSrc="/demo-video.mp4"
  thumbnailSrc="/demo-thumbnail.jpg"
  enableControls
/>

With Custom Overlays

import { PlayIcon } from "lucide-react"
 
import { Spinner } from "@/components/ui/spinner"
 
;<HoverVideoPlayer
  videoSrc="/demo-video.mp4"
  thumbnailSrc="/demo-thumbnail.jpg"
  pausedOverlay={<PlayIcon className="h-12 w-12" />}
  loadingOverlay={<Spinner />}
  hoverOverlay={<div className="text-white">Now Playing</div>}
/>

With Cropping

<HoverVideoPlayer
  videoSrc="/demo-video.mp4"
  thumbnailSrc="/demo-thumbnail.jpg"
  cropTop={10}
  cropBottom={10}
/>

Features

  • Lazy loading with Intersection Observer
  • Mobile touch support with tap-to-play
  • Picture-in-Picture mode
  • Custom overlay support for different states
  • Thumbnail support with smooth transitions
  • Playback controls with volume and progress
  • Responsive design that works across devices
  • Video cropping support for custom positioning
  • Automatic pause when out of viewport