A reusable YouTube video player component with thumbnail preview and play button overlay.
YouTube video URL (supports embed, watch, and short URLs).
Whether the video should autoplay when loaded. Defaults to false.
Optional additional CSS classes.
Optional aspect ratio override. Defaults to aspect-[16/9].
- Smart URL Parsing: Automatically extracts video ID from various YouTube URL formats
- Thumbnail Preview: Shows video thumbnail with play button overlay
- Click to Play: Click the play button to start the video
- Autoplay Support: Configurable autoplay behavior
- Responsive Design: Maintains aspect ratio across screen sizes
- Customizable Styling: Supports custom CSS classes and aspect ratios
import VideoPlayer from './components/VideoPlayer';
<VideoPlayer
videoUrl="https://www.youtube.com/watch?v=dQw4w9WgXcQ"
/><VideoPlayer
videoUrl="https://youtu.be/dQw4w9WgXcQ"
autoplay={true}
/><VideoPlayer
videoUrl="https://www.youtube.com/embed/dQw4w9WgXcQ"
className="my-custom-class"
aspectRatio="aspect-video"
/>The component supports various YouTube URL formats:
https://www.youtube.com/watch?v=VIDEO_IDhttps://youtu.be/VIDEO_IDhttps://www.youtube.com/embed/VIDEO_ID
This component is designed to work seamlessly with the HeroSection component. The HeroSection can now use this VideoPlayer instead of having embedded video logic.