Data Display

VideoThumbnail

Muted, control-free video that stands in for an image: it shows a chosen frame and can play a preview while the pointer or focus is on it.

import { VideoThumbnail } from '@lostgradient/cinder';
mediavideothumbnail
01

Overview

Reference usage

Muted, control-free video that stands in for an image: it shows a chosen frame and can play a preview while the pointer or focus is on it.

VideoThumbnail is the video counterpart of Image. src, label, ratio, and fit mean what src, alt, ratio, and fit mean on Image; label="" marks the thumbnail decorative, as alt="" does. The element is always muted, plays inline, shows no controls, and loads only its metadata until a preview plays.

poster shows an image until playback starts. Without one, posterTime shows a frame of the video itself: the thumbnail moves to that second once the length is known, and no #t= fragment is added to the source, so the URL stays the one the page gave. With both set, poster wins and nothing seeks.

Usage

svelte
<script lang="ts">
  import { VideoThumbnail } from '@lostgradient/cinder';
</script>

<VideoThumbnail
  src="https://example.com/media/intro.mp4"
  label="Product introduction"
  posterTime={1}
  ratio="16 / 9"
/>

Preview on hover

previewOnHover plays the video when a mouse or pen pointer enters, or focus lands in, the preview host. It pauses the video, back on posterTime (the start when it is unset), once neither the pointer nor focus is in the host. Focus moving between controls inside the host keeps the preview playing, and so does a pointer that leaves while focus stays inside. Touch never starts a preview, so a tap starts no download. Under prefers-reduced-motion: reduce, or Cinder's reduced-motion setting, the preview never plays. The host is the closest GridListItem, because that item's stretched link takes the pointer over the thumbnail. Outside one it is the closest link or button, so a linked card's hover and keyboard focus reach the preview, and with neither the thumbnail is its own host.

Unavailable source

A source that is not https:, http: or blob:, or that fails to load, replaces the <video> with a muted video-off glyph in the inset. Pass a fallback snippet to draw something else there. The wrapper carries the accessible name in every state: it is role="img" named by label, and the <video> and the fallback inside it stay hidden from assistive technology. With label="" the wrapper is hidden instead.

svelte
<GridList.Item href="/recordings/intro">
  {#snippet image()}
    <VideoThumbnail
      src="https://example.com/media/intro.mp4"
      label=""
      posterTime={1}
      ratio="16 / 9"
      previewOnHover
    />
  {/snippet}
  {#snippet title()}
    Product introduction
  {/snippet}
</GridList.Item>

Guidance

Use When

  • Showing a video's frame in a card or gallery where an image would sit.
  • Previewing a video on hover or focus without controls, inside a GridListItem.

Avoid When

  • The viewer needs to play, pause, or seek — use VideoPlayer instead.
  • The thumbnail is a still picture — use Image instead.
Live preview

Frame from a time offset

02

When to use

Use when
  • Showing a video's frame in a card or gallery where an image would sit.
  • Previewing a video on hover or focus without controls, inside a GridListItem.
Avoid when
  • The viewer needs to play, pause, or seek — use video-player instead.
  • The thumbnail is a still picture — use image instead.
03

Examples

Frame from a time offset

A frame one second in stands in for the picture, so the thumbnail is not blank. Only https, http, and blob sources load.

Preview on hover in a grid card

In a GridListItem's image snippet the whole card is the hover host, because the card's stretched link takes the pointer over the thumbnail. Hover or focus plays the video; leaving pauses it and returns to the chosen frame.

04

Props

Props for video-thumbnail
Name
Type
Default
Description
src required text Media source. Only https:, http:, and blob: URLs load; any other scheme shows the unavailable glyph, or fallback. No #t= fragment is added: use posterTime to choose the frame.
label required text Accessible name of the video, the counterpart of Image's alt. Pass label="" for a decorative thumbnail whose card already names the video.
poster text Image shown until playback starts. With it set, posterTime does not seek.
posterTime number Second of the video to show, once its length is known, when no poster is set; also where a preview rests when hover or focus ends. Defaults to the start for the resting position. A negative, NaN or infinite value is ignored: nothing seeks and a preview rests on the start. A value past the end of the video shows the last frame.
previewOnHover boolean false Play the video while the pointer or focus is on the preview host, and pause it, back on posterTime, when neither the pointer nor focus is on it. Touch never starts a preview. The host is the closest GridListItem (the whole card, since its stretched link takes the pointer over the thumbnail), else the closest link or button, else the thumbnail itself. Nothing plays under prefers-reduced-motion: reduce.
ratio text CSS aspect-ratio applied to the wrapper (e.g. '16 / 9') so layout is stable while the video loads.
fit 'contain''cover''fill''none''scale-down' How the video fills its box, mapped onto CSS object-fit. Omitted, the video covers the box (cover).
fallback snippet Rendered in place of the <video> when the source is unavailable: a scheme other than https:, http: or blob:, or a load error. Omitted, the inset shows a muted video-off glyph. The wrapper keeps the label either way.