Menu

Components

Media

Screenshots and recordings on a write-up: one frame and caption for every picture, and three ways to show a video.

Usage

Media frame

The Blockpad window: a floating canvas with a filter panel sketched on it, a collapsible inspector rail, and a tool dock along the bottom
A filter panel sketched on Blockpad's canvas, the inspector rail open beside it.

Uses.ssr-loop.ssr-loop-still

import { DemoImage } from '@/components/ui/demo-image'
import { DemoVideo } from '@/components/ui/demo-video'
import { LoopVideo } from '@/components/ui/loop-video'
import { PlateVideo } from '@/components/ui/plate-video'

<figure>
  <div className="aka-card-well aka-card-media overflow-hidden rounded-lg">
    <DemoImage src="/blockpad/blockpad-hero.webp" alt="The Blockpad window" width={1600} height={1003} />
  </div>
  <figcaption className="mt-1.5 text-11 font-light text-muted-foreground/75">What the frame shows.</figcaption>
</figure>

Every screenshot gets the same frame and caption, and the caption states what the frame shows, not that it is a screenshot. DemoImage serves quality 90, because these are pictures of interfaces, hairlines and small caps, the worst case for a lossy codec.

Examples

DemoVideo

<DemoVideo src="/ubik/search" poster="/ubik/search-poster.webp" width={1280} height={952} label="Ubik's search, scoring its own results" />

A screen recording with controls: the poster until play, nothing fetched before it.

LoopVideo

The Ubik home page headline, its highlights arriving one phrase at a time
<LoopVideo src="/ubik/marketing/home-hero" poster="/ubik/marketing/home-hero-poster.webp" width={1280} height={662} label="The Ubik home page headline" />

A recording that plays itself and cannot be stopped: the interface moving on its own, with no control bar turning a picture of the product into a media player.

PlateVideo

Wrdef, mid-game: a guess resolving to green and amber tiles
<div className="aspect-[900/640] overflow-hidden rounded-lg">
  <PlateVideo src="/wrdef/wrdef-card.mp4" poster="/wrdef/wrdef-card-poster.webp" width={900} height={640} label="Wrdef, mid-game" />
</div>

A clip inside a plate, cut for the cell: seven seconds at 900px is 25 KB where the full capture is 1.28 MB.

Props

DemoImage

Server component

PropDescription
srcstring | StaticImageDataA path under /public, or a static import, which brings its own blur.
altstringWhat the picture shows.
width?numberRequired for a path; a static import already knows its own.
height?numberAs width.
sizes?stringThe article's own measure, so a phone is not sent a desktop frame.Default '(min-width: 672px) 640px, 100vw'
priority?booleanPreload it: the largest picture above the fold.
blur?booleanThe 16px blur-up before the bytes arrive. Off where a frame already has a ground of its own.Default true
eager?booleanFetch on load rather than on approach, for a slide reached sideways.
unoptimized?booleanServe the encoded file itself, skipping the optimiser.
className?stringOn the image.

DemoVideo

Server component

PropDescription
srcstringBase path under /public, without extension.
format?'mp4' | 'webm'The container to serve.Default 'mp4'
posterstringShown until play, and the only thing fetched on load.
widthnumberIntrinsic size, so the frame reserves its space.
heightnumberAs width.
labelstringDescribes the recording for anyone who cannot watch it.
className?stringOn the video.Default 'block h-auto w-full'

LoopVideo

Server component

PropDescription
srcstringBase path under /public, without extension.
posterstringThe still, which stands in under reduced motion.
widthnumberIntrinsic size, so the frame holds its shape before anything loads.
heightnumberAs width.
labelstringWhat the recording shows.
className?stringOn the video and its still.Default 'block h-auto w-full'

PlateVideo

Server component

PropDescription
srcstringThe clip, cut for a plate.
posterstringThe still, which stands in under reduced motion.
labelstringWhat the clip shows.
widthnumberIntrinsic size.
heightnumberAs width.

Best practices

When to use

  • DemoImage for every screenshot on a write-up; DemoVideo when the reader should choose to watch; LoopVideo when the motion is the point; PlateVideo inside a project plate.

Behaviour

  • All four are server components with no hooks; a page of recordings ships no JavaScript for its video.
  • Under reduced motion the looping videos are hidden and their still stands in, chosen by the ssr-loop pair in CSS rather than by a script.
  • Every one ships its intrinsic size, so nothing jumps as it loads (law 06).

Accessibility

  • Images take alt text and videos a label that says what they show.
  • The videos are muted and carry an empty captions track.

CSS

The rules, as globals.css has them, with the reasoning the stylesheet keeps beside them.

app/globals.css, line 1693
/*
 * A looping clip's two states, decided in CSS rather than in JavaScript.
 *
 * Motion by default, the poster frame when the reader has asked their system
 * for less. Doing the swap with a media query is what lets a card's video stay
 * a server component: there is no moment where a script has to pick between
 * the two, so neither waits for hydration.
 */
.ssr-loop-still {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .ssr-loop {
    display: none;
  }
  .ssr-loop-still {
    display: block;
  }
}