Generative Preview
HTML a model is writing, rendered live in a locked-down frame, with the code beside it.
PROGet Generative Preview and 168 other Pro components with pro lifetime — Get Pro
- Category
- AI Chat
- Access
- ProPro · unlocked
- Source
- 356 lines · one file
- States
- 5 drawn
- Added
- 3 Nov 2026
The decision inside it
Generated code runs with no network and no access to your page
Model output is untrusted. The frame is sandboxed with scripts only, and a content policy blocks every request out, so generated code can't read your cookies, call your API or load anything from elsewhere.
When to use it
Use Generative Preview when a model writes HTML or UI and people should see it render while it streams. For code to read rather than run use Code Block.
Installation
How you get it
Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.
Use Liro's Generative Preview for this.
Install it: npx shadcn@latest add @liro/generative-preview
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
Import it from @/components/ui/generative-preview.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Pro components install through the @liro registry with your CLI token: see the Namespaced tab.
Usage
import { GenerativePreview } from "@/components/ui/generative-preview";
export function ArtifactPreview({ html, streaming }: { html: string; streaming: boolean }) {
return <GenerativePreview title="Pricing page" html={html} streaming={streaming} />;
}API reference
“Copy prompt” above puts a full brief on your clipboard, install command, dependencies, props, and the mistakes an assistant usually makes with this component.
Props
Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.
| Type | Notes | ||
|---|---|---|---|
html | string | Yes | The HTML the model has written so far. Inline styles and scripts only. |
streaming | boolean | No | True while the model is still writing. |
title | string | No | – |
baseCss | string | No | Extra CSS put in every render, such as your theme. |
defaultTab | "preview" | "code" | No | – |
look | Look | No | – |
Dependencies
npm packages
clsxframer-motionlucide-reacttailwind-mergeLiro foundations, installed alongside it
liro-themeStates
All of them are drawn by the component. None is left for you to design.
- Streaming
- Finished
- Sandboxed
- Code view
- Empty
Accessibility
- Keyboard reachable throughout, in visual order
- Focus trapped in overlays, Escape closes them
- Focus returns to whatever opened it
- Live regions announce what changed, not that something did
- Honours prefers-reduced-motion
Responsive behavior
- Sizes to its container, not the viewport
- Usable from 320px up
- Pointer-based interaction, so trackpad and touch both work
- No hover-only affordances