Primitives

Video

An embedded or self-hosted video player.

Video playback for self-hosted files, YouTube and Vimeo embeds, with aspect ratio options, a floating player, autoplay and hidden controls.

HTML5 video (default aspect)

Standard video player with 16:9 aspect ratio. Supports all modern video formats with full controls.

html5
---
import Video from '@alfadormx/blocks/primitives/Video.astro';
---

<Video
  source={{
    provider: 'html5',
    sources: [
      { src: '/videos/flower.webm', type: 'video/webm' },
      { src: '/videos/flower.mp4', type: 'video/mp4' },
    ],
  }}
/>

YouTube embed

Embed YouTube videos with the same player controls.

youtube
---
import Video from '@alfadormx/blocks/primitives/Video.astro';
---

<Video source={{ provider: 'youtube', id: 'bTqVqk7FSmY' }} />

Vimeo embed

Embed Vimeo videos with the same player controls.

vimeo
---
import Video from '@alfadormx/blocks/primitives/Video.astro';
---

<Video source={{ provider: 'vimeo', id: '1084537' }} />

Square aspect ratio (1:1)

Perfect for social media-style videos or profile content.

ratio-square
---
import Video from '@alfadormx/blocks/primitives/Video.astro';
---

<div class="max-w-lg mx-auto">
  <Video aspectRatio="square" source={{ provider: 'youtube', id: 'bTqVqk7FSmY' }} />
</div>

Portrait aspect ratio (9:16)

Optimized for mobile-first vertical videos.

ratio-portrait
---
import Video from '@alfadormx/blocks/primitives/Video.astro';
---

<div class="max-w-md mx-auto">
  <Video aspectRatio="portrait" source={{ provider: 'youtube', id: 'bTqVqk7FSmY' }} />
</div>

Cinema aspect ratio (21:9)

Ultra-wide cinematic format for immersive content.

ratio-cinema
---
import Video from '@alfadormx/blocks/primitives/Video.astro';
---

<Video
  aspectRatio="cinema"
  source={{ provider: 'html5', sources: [{ src: '/videos/flower.mp4', type: 'video/mp4' }] }}
/>

Floating player behavior

Video follows you as you scroll down the page. Try scrolling past this video to see it float in the corner. Click the arrow button to dismiss it.

floating
---
import Video from '@alfadormx/blocks/primitives/Video.astro';
---

<Video
  isFloating={true}
  pipButton={{ id: 'doc-video-pip', 'aria-label': 'Close floating player' }}
  source={{ provider: 'html5', sources: [{ src: '/videos/flower.mp4', type: 'video/mp4' }] }}
/>

Autoplay with hidden controls

Video starts playing automatically with no controls visible. Autoplay automatically enables muting to comply with browser autoplay policies. Use the muted prop to override this behavior if desired. Looping is also enabled in this example to allow continuous playback.

autoplay
---
import Video from '@alfadormx/blocks/primitives/Video.astro';
---

<Video
  autoplay
  hideControls
  loop
  source={{ provider: 'html5', sources: [{ src: '/videos/flower.mp4', type: 'video/mp4' }] }}
/>

Several floating players

Each floating video docks and closes on its own.

floating-2
---
import Video from '@alfadormx/blocks/primitives/Video.astro';
---

<Video
  isFloating={true}
  pipButton={{ id: 'doc-video-pip-2', 'aria-label': 'Close floating player' }}
  source={{ provider: 'html5', sources: [{ src: '/videos/flower.mp4', type: 'video/mp4' }] }}
/>

API Reference

PropTypeDefaultDescription
sourceVideoSource—What to play: self-hosted files (`html5`) or a YouTube or Vimeo video id.
aspectRatioAspectRatio'video'Aspect ratio of the video box (default: 'video').
isFloatingbooleanfalseDocks the video in the bottom-right corner once it scrolls out of view (default: false).
crossorigin'anonymous' | 'use-credentials''anonymous'Value of the `crossorigin` attribute on a self-hosted `<video>` (default: 'anonymous').
autoplayboolean—Starts playback on load.
mutedboolean—Mutes the video; if unset, defaults to true whenever autoplay is enabled.
hideControlsboolean—Renders the video without player controls.
loopboolean—Restarts playback when the video ends.
classstring''Additional CSS classes merged onto the video wrapper element.
align'left' | 'center' | 'right'—Horizontal alignment of the video wrapper within its container.
pipButtonOmit<ButtonProps, 'hidden'>—Config for the floating player's close button, merged over the default button; the floating player owns `hidden`.