Code-Driven Presentations: A Practical Guide to Generating Interactive Slide Decks with LLMs
This article explains how to use large language models to generate interactive, browser-based presentations as executable code rather than static slides. It covers a three-layer architecture (narrative, scene, runtime), an end-to-end generation pipeline, prompt engineering techniques, an interactive runtime design, code-based visual systems with theme tokens, and practical guidance on performance budgets, accessibility, security, and quality gates. The key takeaway: expressiveness must be paired with engineering constraints—structured scene descriptions, modular runtimes, and automated validation—to turn impressive demos into production-ready deliverables.
Traditional presentations treat the “slide” as the smallest unit: one page of text, a set of charts, a page turn. When large language models move their output beyond copy and images into executable code, the smallest unit of a presentation becomes the “scene”—something that simultaneously contains a timeline, layers, a camera, interaction states, and rendering logic. The presentation is no longer a set of static pages to be watched, but a small interactive application that runs in the browser, responds to input events, and adapts to data or devices.
It is important to clarify that this capability is not the same as “a visual generation model producing video directly.” The key technical path is: the LLM understands narrative intent, generates structured scene descriptions, then generates frontend code, and the browser handles real-time rendering. Code here is both the expressive medium and the delivery format. This brings three direct advantages: first, visual elements are generated via parameters and algorithms, making it easy to maintain a consistent style; second, animations and transitions can be precisely controlled along a timeline; third, interaction, responsive layout, and accessibility fallbacks all live within one engineering system.
1. From Pages to Running Scenes: Redefining the Problem
1.1 Three Layers of a Code-Driven Presentation
A code-driven presentation can be decomposed into three layers.
The first is the narrative layer, answering “what to say”: chapter order, the core message of each segment, emotional pacing, dwell time, and interaction trigger points. The second is the scene layer, answering “how to present it”: scene graphs, layers, cameras, animation, transitions, and sound effects. The third is the runtime layer, answering “how it runs stably”: event handling, state machines, render loops, resource constraints, and fallback strategies.
In traditional presentation tools these three layers are tangled together in page layouts; a code-driven approach explicitly separates them. Once separated, the model can first generate storyboards and scene descriptions, then generate code—and developers can validate narrative, visuals, and runtime logic independently.
1.2 Not Flashier Pages, but a Different Way of Organizing Information
A “scene” can be a 2D infographic, or a 3D space with camera pushes, particle backgrounds, or data visualization. What matters is not whether 3D is used, but whether information is organized into an orchestratable, continuous experience. For example:
- A title page need not be centered big text—it can be a camera shot moving from wide view to close-up;
- A data page need not be a static bar chart—it can progressively unfold along a timeline, with click-to-focus on a specific dimension;
- A section transition need not be a simple fade—chart elements can morph into the spatial objects of the next scene;
- A closing page can retain full replay, keyboard navigation, and a text summary to keep information accessible.
The difference from video is interaction; the difference from an ordinary web page is narrative orchestration. It is essentially a lightweight, deliverable, embeddable interactive narrative application.
1.3 Capability Boundaries and Risks
Code-driven presentations are not a replacement for all reporting formats. For scenarios requiring strict regulatory review, complex collaborative editing, high-precision printing, or heavy rights-managed assets, mature document systems remain the right choice. LLM-generated code can also exhibit confused visual hierarchy, incomplete interaction paths, uncontrollable performance, or security risks. Therefore, engineering must introduce structured constraints, automated checks, and human review.
2. An End-to-End Generation Architecture
A production-ready system typically contains a six-stage pipeline:
- Requirement parsing and narrative planning;
- Structured scene description output;
- Modular code generation;
- Build, static analysis, and automated testing;
- Browser runtime rendering;
- Feedback iteration and version archiving.
The core data structures can be sketched as follows:
type PresentationSpec = {version: string;meta: {title: string;audience: string;duration: number; // total duration in secondsseed: string; // used for reproducible random effects};scenes: SceneSpec[];theme: ThemeTokens;constraints: {noExternalAssets: boolean;maxActiveLayers: number;reduceMotionFallback: boolean;keyboardNavigable: boolean;};};type SceneSpec = {id: string;duration: number;layers: LayerSpec[];enter?: TransitionSpec;exit?: TransitionSpec;interaction?: InteractionSpec[];};type LayerSpec = {id: string;primitive: "text" | "shape" | "chart" | "particle" | "camera" | "audio";props: Record<string, unknown>;animation?: AnimationSpec;};
This structure is not meant to prescribe a fixed interface—it illustrates one principle: have the model generate verifiable scene descriptions before generating rendering code. Throwing “make a cinematic presentation” at the model yields uncontrollable results; decomposing the task into “storyboard — scene graph — rendering modules — interaction states — quality gates” significantly improves stability.
2.1 Narrative Planning Stage
The first stage does not produce final code, but a storyboard. Each scene must specify: the target message, the visual subject, the transition, the estimated duration, interactions, and fallback text. The storyboard should also include a pacing curve—for example, a fast atmospheric opening, gradual explanation in the middle, and a tight conclusion.
Hard constraints should also be written in at this stage:
- When no external assets are allowed, graphics and sound effects must be generated procedurally;
- No network access, avoiding uncontrollable runtime resources;
- Text information must be readable before or after any interaction;
- Animations must respect the system’s “reduced motion” preference;
- Key information must have a static fallback or summary view.
2.2 Structured Description Stage
Converting the storyboard into a scene description like PresentationSpec reduces the instability of free-form LLM output. Structured descriptions also enable schema validation, version comparison, and partial rebuilds. For example, to change only the transition on scene three, you don’t regenerate the entire deck—you just adjust that scene’s enter and exit descriptions.
2.3 Code Generation Stage
Code generation should follow the principle of “a stable runtime, modular scenes.” The runtime handles the timeline, state machine, and render loop; each scene plugs in as an independent module. The model generates only scene modules and configuration, and is not allowed to rewrite the global runtime. This controls complexity and enables incremental changes.
3. Prompt Design: Translating “Impressive” into Engineering Constraints
A vague prompt like “make the most impressive presentation” provides direction but nothing verifiable. A professional prompt needs a role, deliverables, structure, constraints, and acceptance criteria.
A reference template:
You are an interactive narrative director and frontend architect. Design a self-contained,browser-runnable interactive presentation on the topic of [topic].The audience is [audience], the total duration is about [duration] seconds, and the keytakeaway is [takeaway].Stage one: output only a storyboard. Each slide specifies the scene goal, visual subject,transition, duration, interactions, and text fallback.Stage two: output the scene descriptions and modular code. Requirements:1. No external assets or network requests; graphics, animation, and audio are generated procedurally;2. Use unified theme tokens to control colors, font sizes, spacing, and animation curves;3. Provide keyboard navigation, captions/summaries, and a reduced-motion mode;4. Use a fixed seed for all random effects to ensure consistent results across runs;5. Set a layer-count cap for the render loop and provide degradation strategies for low-power devices;6. Do not generate dangerous calls, remote loading, or unauditable dependencies.
The point is not to limit the model’s creativity, but to place creativity in narrative and visual language while placing stability in engineering constraints. One effective practice: have the model first propose three narrative directions in its first output, let a human choose one, then proceed to storyboards and code. This preserves generative exploration while avoiding a flood of unusable code generated in one shot.
4. The Interactive Runtime: Timeline, State Machine, and Reproducibility
The runtime of a code-driven presentation can be understood as a “controlled animation player + interaction state machine.” The timeline advances animations; the state machine handles play, pause, focus, rewind, and interactive expansion.
Illustrative pseudocode:
type PlayState = "idle" | "playing" | "paused" | "focused" | "ended";function createRuntime(spec: PresentationSpec) {let state: PlayState = "idle";let currentScene = 0;let elapsed = 0;function update(deltaMs: number) {if (state !== "playing") return;elapsed += deltaMs;const scene = spec.scenes[currentScene];if (elapsed >= scene.duration * 1000) {elapsed = 0;currentScene = Math.min(currentScene + 1, spec.scenes.length - 1);}}function render(frameTime: number) {const scene = spec.scenes[currentScene];const progress = elapsed / (scene.duration * 1000);// Update layers, camera, and transitions based on the scene descriptionupdateLayers(scene, progress);drawScene(scene);if (state === "playing") {scheduleNextFrame(render);}}function handleInput(event: InputEvent) {if (event.type === "next") {currentScene = Math.min(currentScene + 1, spec.scenes.length - 1);elapsed = 0;}if (event.type === "togglePause") {state = state === "playing" ? "paused" : "playing";}}return { update, render, handleInput };}
This code only expresses responsibility allocation. Real implementations must also handle:
- Focus transitions: when a user clicks a data point, does the camera zoom in, and does the animation pause?
- Input consistency: do keyboard, touch, and mouse operations map to the same semantic actions?
- Reversibility: when returning to a previous scene, can state be restored to a predictable position?
- Determinism: particles, noise, and random distributions use fixed seeds so the experience looks the same every time;
- Testability: state transitions should not depend on real time, but should be drivable by a virtual clock.
5. Code-Based Visuals: Trading Parameters for Consistency
When visuals are generated by code, the most important thing is not stacking effects but building a parameter system. Colors, font sizes, spacing, corner radii, shadows, easing curves, and camera speeds should all come from theme tokens. The same tokens can be reused across 2D charts, 3D spaces, and typography, so the deck stays stylistically unified no matter how many scenes there are.
Procedural visuals usually fall into four categories:
- Geometry and graphics: rectangles, paths, gradients, masks, particle fields;
- Data visualization: axes, scales, data markers, and animated transitions;
- Camera and space: zoom, rotation, depth-of-field simulation, layer displacement;
- Procedural audio: simple synthesis for rhythm or cues, muted by default with captions/text summaries provided.
Visual complexity must serve the information. If animation makes text unreadable, hides key data, or causes discomfort through frequent flickering, it should proactively degrade. An “information-first mode” can be built in: disable particles and large camera movements, keeping only layered reveals and fades.
6. Performance, Accessibility, and Security
6.1 Performance Budgets
Code-generated presentations easily spiral out of control in layer counts, particles, and real-time computation. Set budgets at design time: cap the number of simultaneously active layers, limit per-frame repaint scope, cache static drawing results, and pause rendering when the window is not visible. For 3D and particle-heavy scenes, offer a low-quality fallback rather than running the same complexity on every device.
6.2 Accessibility
Presentation content should have semantic text, a clear focus order, keyboard navigation, and captions or bullet-point summaries. Dynamic effects should respect the system’s reduced-motion preference; continuous animations should have a pause control; purely visual expressions should have equivalent text descriptions. Accessibility is not just a compliance item—it is what allows the content to remain consumable in screen recordings, screenshots, search results, and low-bandwidth environments.
6.3 Security Boundaries
LLM-generated code must be treated as untrusted input. In production, at minimum: run it in an isolated browsing context, deny network requests by default, restrict callable capabilities, perform static scanning and dependency auditing, and block execution of unreviewed remote code. For enterprise content, generation, review, build, and release should run in separate environments so that every release is traceable.
7. Quality Gates and Evaluation
A piece that “looks like it plays” is still far from a deliverable system. Establish multiple layers of quality gates:
- Content correctness: do facts, numbers, and citations match the source material, and are key conclusions recorded in text?
- Narrative completeness: does the scene order cover the outline, and do transitions explain relationships rather than merely decorate?
- **Interaction robustness”: does the deck still work after rapid clicking, fast rewinding, and window resizing?
- Visual stability: is the hierarchy still clear at different resolutions, with font fallbacks, and on low-power devices?
- Runtime performance: sample on real target devices, watching for jank, memory growth, and initial-load wait times;
- Accessibility: do keyboard operation, summary views, reduced motion, and contrast meet the bar?
- Maintainability: are scene modules decoupled, theme tokens centralized, and repeated code abstractable?
- Security: are there remote loads, dangerous calls, unbounded resource consumption, or privacy leaks?
Automation can cover builds, type checking, unit tests, visual snapshots, and resource checks, but narrative quality and factual accuracy still require human review. A more reliable process: the model generates the storyboard, a human confirms the narrative; the model generates code, automation performs engineering checks; a human performs final content review; and a reproducible version is archived.
8. Engineering Recommendations for Production
First, manage “generating a presentation” as “generating a runnable deliverable.” It needs source code, configuration, build artifacts, version history, and rollback mechanisms—not a one-off chat output. Second, maintain the template library and the runtime separately. The model can reuse stable scene skeletons, theme tokens, and the interaction state machine, generating only local variations, which lowers the failure rate. Third, separate presentation data from rendering code. Data flows into scenes through structured input, avoiding hard-coding volatile business information into animation logic.
For deployment, build static artifacts into object storage, accelerate access via CDN, and hook into logging and monitoring to observe load failures, interaction anomalies, and performance regressions. Generation tasks should run in isolated execution environments and pass review before release. For continuously updated content, rebuild via “template + data + incremental scenes” rather than full regeneration each time.
Conclusion
The real value of LLMs generating interactive presentations through code is not producing a one-off visual spectacle, but opening up the full pipeline of “narrative planning → scene description → code implementation → runtime delivery.” Once code becomes the expressive medium, presentations can have timelines, interaction, responsive behavior, and accessibility—and they can be tested, reused, and versioned.
But greater expressiveness demands stronger engineering discipline. Controlled structured descriptions, a modular runtime, strict performance budgets, accessibility design, and a security sandbox are what move this approach from demo to production. Decomposing “impressive” into executable, verifiable steps is the most worthwhile technical direction for code-driven presentations.
