Veil UI
Components

Video Player

A native video player with poster and caption support.

Installation

$ npx veil-ui@latest add video-player

Usage

import { VideoPlayer } from "@/components/ui/video-player";

<VideoPlayer src="/clip.mp4" poster="/poster.jpg" caption="Spring in motion" />;

Examples

Basic

A short clip of flowers in the wind.

Auto play

Muted looping background clip.

API reference

The package exports video-player along with its composable parts. It forwards standard attributes to its root element; see the examples above for the component-specific props.

Accessibility

  • Media players use native <video> and <audio> controls with accessible labels.
  • Images require meaningful alt text; clickable thumbnails are buttons named Play <title>.
  • Decorative play overlays, durations and icons are hidden from assistive technology.

Vue and plain HTML

This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add video-player --framework vue or switch the framework in components.json.

<script setup lang="ts">
import { cn } from "@/lib/utils";

const props = withDefaults(
  defineProps<{
    src: string;
    poster?: string;
    caption?: string;
    videoClassName?: string;
    autoPlay?: boolean;
    muted?: boolean;
    loop?: boolean;
    controls?: boolean;
    class?: string;
  }>(),
  { controls: true },
);
</script>

<template>
  <figure data-slot="video-player" :class="cn('w-full max-w-xl', props.class)">
    <video
      :src="src"
      :poster="poster"
      :controls="controls"
      :autoplay="autoPlay"
      :muted="muted"
      :loop="loop"
      playsinline
      preload="metadata"
      :aria-label="caption ?? 'Video'"
      :class="
        cn(
          'aspect-video w-full rounded-lg border bg-black object-contain',
          videoClassName,
        )
      "
    />
    <figcaption v-if="caption" class="mt-2 text-xs text-muted-foreground">
      {{ caption }}
    </figcaption>
  </figure>
</template>

On this page