The 3 AM Page: When Preview Chrome Becomes Render Artifact

You wake to an alert: the automated video pipeline produced 47 corrupted exports overnight. Frame one shows your application's sidebar. Frame twelve captures a modal mid-transition. The encoder did exactly what you asked—it rendered the HTML you gave it, including the preview interface you forgot was part of the DOM tree.

This is the failure mode I am addressing while evaluating heygen-com/hyperframes. Its premise, "Write HTML. Render video," makes HTML the production artifact. A preview dialog, responsive sidebar, or entrance animation must never quietly become part of that artifact.

For a React application using Tailwind CSS v4 and Radix primitives, my recommendation is straightforward: isolate the render document, and animate only the surrounding interface.

One Document, Two Consumers

The architecture has three responsibilities.

The application produces a self-contained HTML document. The preview interface displays that document without modifying it. A render adapter submits the same document, together with explicit viewport and timing settings, to the video-rendering workflow.

That adapter is where Hyperframes integration belongs. I am not assuming a particular repository command, rendering API, or timing contract here; those require verification against the version being adopted. The implementation below deliberately stops at the document boundary.

Do not export the React application root. That couples video output to navigation, portal placement, loaded application styles, and whatever animation happens to be running when capture begins.

Instead, treat the generated HTML as immutable input. Fonts, images, viewport dimensions, and the selected scene time are part of its rendering contract—not incidental browser state.

Why the Tutorial Version Breaks

A common preview implementation measures a panel with getBoundingClientRect(), writes a new width, then repeats that process on the next animation frame. The read after the write can force synchronous layout. Add text wrapping and image decoding, and a smooth-looking demo becomes a source of dropped preview frames and unstable measurements.

Moving the same animation into CSS does not automatically fix it: animating width or height still requires layout work. Use transforms and opacity for interface motion, and reserve fixed dimensions for the rendered document.

The related accessibility failure comes from treating a modal as an absolutely positioned <div>. Adding aria-modal="true" does not implement focus containment, Escape handling, or focus restoration. Keyboard navigation can continue behind the overlay while screen-reader users encounter a misleading dialog boundary.

Both failures come from giving preview chrome responsibilities it should not own.

A Reusable Preview Boundary

In an existing React/TypeScript application configured for Tailwind v4, install @radix-ui/react-dialog. Save this component as VideoPreview.tsx and import the stylesheet below through your application entry point.

import * as Dialog from "@radix-ui/react-dialog"; type VideoPreviewProps = { html: string; }; export function VideoPreview({ html }: VideoPreviewProps) { return ( <Dialog.Root> <Dialog.Trigger asChild> <button type="button" className="rounded-md bg-slate-900 px-4 py-2 text-white focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-blue-600" > Preview video document </button> </Dialog.Trigger> <Dialog.Portal> <Dialog.Overlay className="fixed inset-0 z-40 bg-black/60" /> <Dialog.Content className="preview-dialog fixed inset-4 z-50 m-auto h-fit max-h-[calc(100dvh-2rem)] max-w-5xl overflow-auto rounded-xl bg-white p-4 shadow-xl" > <Dialog.Title className="text-lg font-semibold"> Video document preview </Dialog.Title> <Dialog.Description className="mt-1 text-sm text-slate-600"> Static visual inspection. Final timing is controlled by the render workflow. </Dialog.Description> <div className="preview-shell mt-4"> <div className="preview-layout"> <iframe title="Isolated video document" srcDoc={html} sandbox="" referrerPolicy="no-referrer" className="aspect-video w-full border-0 bg-slate-950" /> <p className="text-sm text-slate-600"> Preview chrome is excluded from the video document. </p> </div> </div> <Dialog.Close asChild> <button type="button" className="mt-4 rounded-md border px-3 py-2 focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-blue-600" > Close preview </button> </Dialog.Close> </Dialog.Content> </Dialog.Portal> </Dialog.Root> ); } 

Radix supplies the modal interaction model and connects the title and description. The iframe gives the document a separate styling context; the surrounding Tailwind utilities cannot accidentally restyle its headings or captions.

Configure Motion Around the Artifact

This is the complete CSS configuration and micro-interaction:

@import "tailwindcss"; .preview-shell { container-type: inline-size; } .preview-layout { display: grid; gap: 1rem; } @container (min-width: 48rem) { .preview-layout { grid-template-columns: minmax(0, 1fr) 12rem; align-items: start; } } @keyframes preview-enter { from { opacity: 0; transform: translateY(0.5rem); } to { opacity: 1; transform: translateY(0); } } @media (prefers-reduced-motion: no-preference) { .preview-dialog[data-state="open"] { animation: preview-enter 160ms ease-out both; } } 

The container query responds to available dialog space rather than assuming the browser viewport describes the component's layout. The entrance animation never changes the iframe's document.

The Trade-offs Are Intentional

This preview is static. Its empty sandbox disables scripts, so it cannot faithfully preview a document that depends on JavaScript-driven animation. That limitation is preferable to silently executing arbitrary generated code inside the application's trust boundary. A scripted preview needs a separately designed isolation policy.

Likewise, aspect-video describes the preview box, not a guaranteed export resolution. For pixel-sensitive work, render the document at its exact production viewport and scale that surface for inspection. Otherwise, line wrapping can differ between preview and export.

The sandbox also does not make HTML network-isolated. External images and styles can still create requests. Use controlled assets and an appropriate content security policy when documents are untrusted.

Before adoption, test keyboard entry, Escape, focus restoration, reduced motion, and representative documents with a screen reader. Radix handles the outer dialog; it cannot repair inaccessible content inside the iframe.

The architectural payoff is modest but important: Hyperframes receives a document, not a screenshot of your application. Preview improvements remain interface changes instead of becoming accidental changes to the video.

The Isolation Dilemma

The empty sandbox solves the trust boundary problem but creates a fidelity gap. If your video document legitimately requires scripted animation—timed transitions, chart rendering, dynamic text layout—this preview cannot show it. The alternative, enabling scripts, means previewing untrusted or generated HTML inside your application's security context.

How are you solving scripted preview safely? Separate worker context? Sandboxed subprocess? Different trust model entirely? I would value hearing how production teams are navigating this trade-off."