Skip to content

← All components

Display and feedback

VideoPlayer

Responsive native video playback with caption and aspect-ratio support.

Live example

0:00 / 0:03
Themed controls remain available to keyboard and assistive technology users.

Usage

Each example includes the complete adapter-specific parameter reference. Copy it as a starting point, then remove options your use case does not need.

React

tsx
import { VideoPlayer } from "@cofob/design-system-react";

/**
 * Complete VideoPlayer parameter reference.
 * @param src
 *   type: string URL
 *   default: —
 *   example: "/video/demo.webm"
 * @param label
 *   type: string | renderable content
 *   required
 *   example: "Product demo"
 * @param caption
 *   type: string | renderable content
 *   default: —
 *   example: "A short product walkthrough."
 * @param aspectRatio
 *   type: CSS aspect-ratio string
 *   default: "16 / 9"
 *   example: "16 / 9"
 * @param durationHint
 *   type: number (seconds)
 *   default: 0
 *   example: {durationHint}
 * @param disabled
 *   type: boolean
 *   default: false
 *   example: {disabled}
 * @param labels
 *   type: Partial<Record<string, string>>
 *   default: —
 *   example: {{ system: "System theme", light: "Light theme", dark: "Dark theme" }}
 * @param videoProps
 *   type: native video element attributes
 *   default: —
 *   example: {videoProps}
 * @param children
 *   type: ReactNode | Svelte Snippet | child HTML
 *   default: —
 *   example: children / snippet / child HTML
 * @param figure attributes
 *   type: native element attributes
 *   default: —
 *   example: class / style / aria-* / data-*
 */
export function VideoPlayerExample() {
  return (
    <VideoPlayer src="/video/demo.webm" label="Product demo" />
  );
}

Svelte

svelte
<script lang="ts">
  import { VideoPlayer } from "@cofob/design-system-svelte";

  // Complete VideoPlayer parameter reference.
  // src
  //   type: string URL
  //   default: —
  //   example: "/video/demo.webm"
  // label
  //   type: string | renderable content
  //   required
  //   example: "Product demo"
  // caption
  //   type: string | renderable content
  //   default: —
  //   example: "A short product walkthrough."
  // aspectRatio
  //   type: CSS aspect-ratio string
  //   default: "16 / 9"
  //   example: "16 / 9"
  // durationHint
  //   type: number (seconds)
  //   default: 0
  //   example: {durationHint}
  // disabled
  //   type: boolean
  //   default: false
  //   example: {disabled}
  // labels
  //   type: Partial<Record<string, string>>
  //   default: —
  //   example: {{ system: "System theme", light: "Light theme", dark: "Dark theme" }}
  // videoProps
  //   type: native video element attributes
  //   default: —
  //   example: {videoProps}
  // children
  //   type: ReactNode | Svelte Snippet | child HTML
  //   default: —
  //   example: children / snippet / child HTML
  // figure attributes
  //   type: native element attributes
  //   default: —
  //   example: class / style / aria-* / data-*
</script>

<VideoPlayer src="/video/demo.webm" label="Product demo" />

HTML

html
<!--
  Complete VideoPlayer parameter reference.
  src
    type: string URL
    default: —
    example: "/video/demo.webm"
  label
    type: string | renderable content
    required
    example: "Product demo"
  caption
    type: string | renderable content
    default: —
    example: "A short product walkthrough."
  aspectRatio
    type: CSS aspect-ratio string
    default: "16 / 9"
    example: "16 / 9"
  durationHint
    type: number (seconds)
    default: 0
    example: {durationHint}
  disabled
    type: boolean
    default: false
    example: {disabled}
  labels
    type: Partial<Record<string, string>>
    default: —
    example: {{ system: "System theme", light: "Light theme", dark: "Dark theme" }}
  videoProps
    type: native video element attributes
    default: —
    example: {videoProps}
  children
    type: ReactNode | Svelte Snippet | child HTML
    default: —
    example: children / snippet / child HTML
  figure attributes
    type: native element attributes
    default: —
    example: class / style / aria-* / data-*
-->
<figure class="cf-video-player" data-cf-video-player data-started="false"><div class="cf-video-player__frame"><video class="cf-video-player__media" src="/video/demo.webm" aria-label="Product demo" controls data-cf-video-media></video><button class="cf-video-player__start" type="button" aria-label="Play video" data-cf-video-start>…</button><div class="cf-video-player__controls">…</div></div></figure>

<script type="module">
  import { initDesignSystem } from "@cofob/design-system-css";

  const designSystem = initDesignSystem(document);
  window.addEventListener("pagehide", () => designSystem.destroy(), { once: true });
</script>

Parameters

Adapter differences are explicit. Native element attributes are forwarded in React and Svelte and can be written directly in HTML.

ParameterTypeDefaultAdaptersExampleDescription
srcstring URLReact · Svelte · HTML"/video/demo.webm"Media URL loaded by the native audio or video element.
labelrequiredstring | renderable contentrequiredReact · Svelte · HTML"Product demo"Visible or accessible name, depending on the component.
captionstring | renderable contentReact · Svelte · HTML"A short product walkthrough."Visible caption for a figure or table.
aspectRatioCSS aspect-ratio string"16 / 9"React · Svelte · HTML"16 / 9"Reserves layout space before the image loads.
durationHintnumber (seconds)0React · Svelte · HTML{durationHint}Known duration used before metadata loads or when duration metadata is unavailable.
disabledbooleanfalseReact · Svelte · HTML{disabled}Prevents user interaction while preserving visible context.
labelsPartial<Record<string, string>>React · Svelte · HTML{{ system: "System theme", light: "Light theme", dark: "Dark theme" }}Localized visible and accessible labels.
videoPropsnative video element attributesReact · Svelte · HTML{videoProps}Forwards muted, poster, preload, cross-origin, event, and other native video attributes.
childrenReactNode | Svelte Snippet | child HTMLReact · Svelte · HTMLchildren / snippet / child HTMLIdiomatic adapter composition content.
figure attributesnative element attributesReact · Svelte · HTMLclass / style / aria-* / data-*Forwards native class/style, accessibility, event, and data attributes to the root element.