Writing Interactive Demos with LLMs as Runnable Code

    Large language models excel at turning intent into structured, runnable code. This article explains how to replace static slides and exported video with small, browser-rendered demos: the problem they solve, a four-layer stack (narrative, visual system, motion, runtime), how constraints improve aesthetics, and how to ship them as maintainable engineering assets.

    Large language models are strongest at understanding intent and generating structured text. One of the most practical outputs is runnable code. When a demo no longer depends on a long video but on live rendering in the browser, slides, charts, scene transitions, and even a simple 3D space can become a compact web page. This article treats that capability as engineering: what problem it solves, how to layer the stack, how to balance aesthetics with control, and how enterprises can turn it into a maintainable deliverable.

    Why demos feel trapped in templates

    “Have the model write slides” is already common. The usual path is outline and speaker notes from the model, then a fixed template. Content can be acceptable while the visual rhythm stays page-flip static. Product launches, internal roadshows, and product explainers often need spatial sense, camera language, and interaction more than another pretty palette: charts that “stand up” off the plane, transitions that feel cinematic, and a full-screen live experience in the browser.

    Video generation can produce frames, but demos need to be editable, reusable, and auditable. Code-driven demos have those properties by default: every frame is defined by HTML, CSS, and script; the package is often only a few megabytes; open a browser and it renders—no long pre-export. For developers and enterprises, that means versions in a repository, diffs in review, and brand rules in components rather than a one-off film.

    Capability boundary: the model writes scenes, not pixels

    A general-purpose LLM is not a pixel-oriented video system. It translates natural-language requirements into page structure, style rules, animation timelines, and interaction logic. Roles, scenes, transitions, and even simple programmatic sound cues can land as code, not as an uneditable pixel stream.

    That raises the bar for taste. The model must write pages that run and encode hierarchy, whitespace, depth, easing curves, and camera motion. When a 2D chart is mapped into 3D and page turns become continuous camera moves, the result no longer feels like a traditional deck. Underneath it is still front-end rendering: the DOM, cascading styles, transform matrices, keyframes, and timing functions. What often exceeds expectations is not new hardware, but the model encoding design language more completely into implementation details.

    Technical layers: from document to real-time 3D narrative

    Organize a live-rendered demo in four layers so logic is not dumped into a single script.

    Layer 1 — Narrative structure. Split the talk into scenes, each with a clear information goal: problem, comparison, mechanism, call to action. Scene count need not be large; camera and information density should match. Each scene should have enter, hold, and leave states so transitions are easy to attach.

    Layer 2 — Visual system. Unify palette, type scale, grid, and shadow. A full game engine is optional: CSS 3D transforms, perspective, stacking, and parallax can lift cards, bars, and timelines off the plane. Heavier meshes, particles, or camera paths can use Canvas or a general 3D API, still under the same design tokens so every page is not a one-off.

    Layer 3 — Motion design. Transitions are not only fades. Combine translation, scale, rotation, and blur to suggest push and cut. Timing functions set character: overshoot for emphasis, ease-in-out for data. Durations should be configurable so the speaker can control pace. If background audio is procedural or lightweight, bind it to the timeline and provide a mute switch for meeting rooms.

    Layer 4 — Runtime and size. Aim for a single page or a few static assets. Compress resources, subset fonts, prefer procedural textures over large bitmaps. Real-time rendering must consider low-end devices: lower shadow quality, fewer simultaneous moving layers, unload inactive scenes. A pack of a dozen scenes at a few megabytes often distributes better than video of similar look.

    A schematic structure (generic front-end pattern, not a product-specific API):

    1. <section class="scene" data-id="intro">
    2. <div class="stage" style="transform-style: preserve-3d;">
    3. <article class="slide-card">...</article>
    4. </div>
    5. </section>
    1. .stage { perspective: 1200px; }
    2. .scene.is-active .slide-card {
    3. animation: enter 900ms cubic-bezier(0.22, 1, 0.36, 1) both;
    4. }
    5. @keyframes enter {
    6. from { transform: translateZ(-240px) rotateX(8deg); opacity: 0; }
    7. to { transform: none; opacity: 1; }
    8. }
    1. function goTo(index) {
    2. scenes.forEach((el, i) => el.classList.toggle("is-active", i === index));
    3. syncAudio(index);
    4. }

    The point is not the syntax but a clear scene state machine: index, direction, skip policy, and how accessibility focus moves.

    Why aesthetics improve: constraints beat “make it pretty”

    If the prompt only says “make it look better,” the model piles on effects. Put constraints in the brief: max simultaneous animation layers, no more than three primary colors, one data takeaway per scene, disable expensive filters on mobile. Constraints force composition and cut noise.

    Another rule: information before camera. Decide the number or judgment the audience must read in three seconds, then how the camera moves. Otherwise transitions steal attention. When charts enter 3D, keep axes readable: strong perspective makes bar heights hard to compare; a slight tilt beats exaggerated vanishing points.

    Hand-drawn looks, comic storyboards, and light 3D can be vector paths, procedural textures, and layered masks. They feel like “generated animation” but are timeline-driven vectors and meshes. That is friendlier for copyright and brand: assets live in code, so corporate identity is swappable instead of locking to an uncontrollable film look.

    Engineering: from a one-off wow to a maintainable asset

    A demo that exists only as a single generation has limited value. Treat it as ordinary front-end work.

    Versioning and review. Scene copy, data, and style tokens in separate files; generated output goes through code review. Sensitive language and unpublished metrics must not ship in a public page.

    Accessibility and fallback. Keyboard paging, reduced-motion, adequate contrast. If 3D fails, fall back to static cards so the talk continues.

    Data separation. Chart data from config or an API, not hardcoded inside animation functions. Quarterly updates change config, not the camera.

    Security and supply chain. If the page embeds scripts, use a content security policy, lock dependencies, and run basic scanning. Do not pull unknown third-party scripts for effects.

    On the cloud side, generic capabilities fit: static hosting on object storage and a CDN, access logs into a logging service, alerts for errors. A container platform can unify the build pipeline. The point is connecting generate–build–publish–observe. Where needed, those category-level services can be combined on platforms such as Baidu AI Cloud without tying the demo to a specific generator.

    Prompts and collaboration: move design review earlier

    Work in rounds, not one request for a finished film. Round one: information architecture and scene list. Round two: static composition. Round three: motion. Round four: size and compatibility. Accept each round with a runnable preview so unreadability is not discovered at the end.

    Prompts should include device profile (projector, laptop, phone), talk length, and whether autoplay is allowed. Autoplay fits online distribution; live talks prefer manual step. Both can share the same scene state machine and only switch the clock source.

    Roles can split: content owns conclusions, visual owns tokens, engineers own the state machine and performance budget, the model lays down boilerplate. People judge; the model expands detail. That is more stable than a single chat.

    Fit and non-fit

    Fit: concept launches, technical explainers, internal training, interactive data stories—audiences who need to follow the camera through a structure, not a skippable ad.

    Not a fit: photoreal film, complex physics, long-take live-action look. Those still belong to dedicated visual generation or traditional production. Also not a fit: irreversible compliance copy fully delegated to one generation. Contracts and safety statements still need human sign-off.

    Do not judge only by views. Measure page weight, time to first interaction, low-end frame rate, cost of changing one line of copy, and accessibility pass rate. Those decide whether it belongs in an enterprise asset library.

    Takeaway

    When a language model writes the demo as live-rendered code, slides stop being templated documents and become versioned front-end apps. Impact comes from perspective, transitions, and timelines—not an uneditable video stream. Govern narrative, visual tokens, motion, and runtime size separately, then add review, fallback, and observability, and a one-off wow becomes a repeatable capability. For developers, the next step is not chasing a viral piece but a scene state machine and a performance budget so generative output survives the meeting room and long-term maintenance.