PreviewFrame
neon-ui/preview-frameFreeComponent
Sandbox iframe with wake, restart, and refresh lifecycle, reload-on-signal, and chrome header.
Install it
npx shadcn@latest add https://ui.neon.com/r/preview-frame.jsonSource
1"use client";23import type { ComponentProps, ReactNode } from "react";4import { useState } from "react";56import { AnimatedWash } from "@/components/animated-wash/animated-wash";7import { NeonLoader } from "@/components/neon-loader/neon-loader";8import { Button, buttonVariants } from "@/components/ui/button";9import { cn } from "@/lib/utils";1011export type PreviewFrameState = "ready" | "sleeping" | "waking" | "error";1213export type PreviewFrameProps = Omit<ComponentProps<"div">, "title"> & {14 /** The sandbox URL the frame renders. */15 src: string;16 /**17 * What the header readout shows when the real src is an internal18 * sandbox host. Defaults to src.19 */20 displaySrc?: string;21 /** Accessible name for the iframe, e.g. the app's name. */22 title: string;23 /**24 * Lifecycle state: "ready" shows the app, "sleeping" dims it behind25 * a wake-on-click scrim, "waking" covers it with the loader while26 * the sandbox spins up, "error" offers a restart.27 */28 state?: PreviewFrameState;29 /** Renders the wake action in the sleeping state. */30 onWake?: () => void;31 /** One line under the sleeping title. */32 sleepingDetail?: string;33 /**34 * Bump this number to force a reload from outside — e.g. after the35 * agent finishes an edit. Merged with the internal refresh count.36 */37 reloadSignal?: number;38 /** Renders the restart action (header and error panel). */39 onRestart?: () => void;40 /** Notified after the built-in refresh action reloads the frame. */41 onRefresh?: () => void;42 /** One line of detail under the error title. */43 errorDetail?: string;44 /** Copy under the loader while waking. */45 wakingLabel?: string;46 /** Extra actions rendered before the built-in header buttons. */47 actions?: ReactNode;48 /**49 * The agent is editing the app right now: the header dot breathes and a50 * quiet "editing…" readout joins the URL. The app stays visible — it is51 * still live and hot-reloading under the changes.52 */53 working?: boolean;54 /** The iframe sandbox policy. */55 sandbox?: string;56};5758/* ─────────────────────────────────────────────────────────59 * LIFECYCLE STORYBOARD60 *61 * The chrome stays constant; only the stage changes. Every62 * overlay is absolute, so the frame never changes height.63 *64 * ready the app, full bleed; the header dot holds65 * primary and the URL reads in mono66// … truncated
What it pulls in
Other registry items
Files it writes
More from neon-ui
All 77 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| ActivityFeedactivity-feed | neon-ui | Components | Free | 2 deps | |
| AgentChatagent-chat | neon-ui | Components | Free | 6 deps | |
| AnimatedWashanimated-wash | neon-ui | Components | Free | no deps · 2 files | |
| ApiKeyListapi-key-list | neon-ui | Components | Free | 2 deps | |
| AppCardapp-card | neon-ui | Components | Free | 2 deps | |
| AppCreatorapp-creator | neon-ui | Components | Free | 2 deps | |
| AuthFormauth-form | neon-ui | Components | Free | no deps | |
| AutoscaleChartautoscale-chart | neon-ui | Components | Free | 1 dep |
