Skip to main content

Starwind UI v1.15 is now available! With new prose, sidebar, and more components

Video

Installation

Usage

General Notes

The Video component automatically detects the video type from the source URL and renders either a native HTML5 <video> element or a YouTube <iframe> embed. It supports:

  • Native videos: Local files, imported assets, or direct video URLs
  • YouTube videos: Standard YouTube URLs, short URLs, and embed URLs
  • YouTube Shorts: Automatically detected and rendered with appropriate settings

YouTube Video

Pass a YouTube URL directly to the src prop. The component handles URL parsing and creates a privacy-enhanced embed using youtube-nocookie.com.

YouTube Shorts

YouTube Shorts are automatically detected and rendered appropriately. Use custom aspect ratio classes to display them correctly.

API Reference

Video

A unified video component that renders either a native <video> element or a YouTube <iframe> based on the source URL.

PropTypeDefault
srcstring-
titlestring"Video"
autoplaybooleanfalse
mutedbooleanfalse
loopbooleanfalse
controlsbooleantrue
posterstring-
classstring-
<Video
src={videoSource}
title="My video"
controls
muted
class="rounded-lg"
/>

Additional Notes:

  • src: Video source URL. Accepts imported video assets, direct URLs, or YouTube URLs (including shorts)
  • title: Used as the iframe title for YouTube embeds (accessibility)
  • autoplay: Auto-starts playback. For YouTube, this sets the autoplay=1 parameter
  • muted: Mutes the video. Required for autoplay in most browsers
  • loop: Loops the video. For YouTube, this also sets the playlist parameter
  • controls: Shows video controls. Set to false to hide them
  • poster: Poster image URL for native videos (not applicable to YouTube embeds)

Changelog

v1.0.0

  • Initial release with starwind v1.13.0