Skip to content

Shared

Device frame preview

Wraps a preview in a desktop or mobile device frame.
Available
Ports as-is

Examples

Rendered live from the maintained Storybook story. Lantern stores only the story id and embeds Storybook rather than duplicating the component or its demo.

Device frame preview

Rendered live from Storybook

Storybook must be running for this to load — bun run start:storybook from the monorepo root, or set NEXT_PUBLIC_STORYBOOK_URL to a deployed instance.

Props

The component's public API, read from its TypeScript source. Descriptions come from TSDoc on the prop, so this table cannot drift from the component.

PropTypeDefaultDescription
childrenReactNode—Preview content, rendered at true viewport size (1280x800 desktop, 390x844 mobile) and scaled down into the frame. Prefer this over `iframeSrc` — it is what keeps the preview self-contained.
iframeSrcstring—URL to render inside an iframe instead of `children`. The app passes a live space URL here; stories must leave it undefined, since loading one would be an external network request.
initialDevicePreviewDevice"desktop"Device shown on first render when uncontrolled.
devicePreviewDevice—Controlled device. When provided, the internal state is bypassed entirely, so each device is a static story rather than a click path.
onDeviceChange(device: PreviewDevice) => void—Fired when the user picks a device from the switcher.
scalenumber—Fixed outer scale. When omitted, the frame measures its container with a ResizeObserver and fits itself; passing an explicit value skips measurement so the render is deterministic.
desktopFrameSrcstringDEFAULT_DESKTOP_FRAMEFrame overlay images. Must be `data:` URIs or bundled assets.
mobileFrameSrcstringDEFAULT_MOBILE_FRAMEUndocumented — add TSDoc to the prop in the library.
classNamestring—Undocumented — add TSDoc to the prop in the library.

Reference

Transcribed from the component audit. If this disagrees with the source, the source is right.

Source
src/components/shared/DeviceFramePreview.tsx
Portability
Copies across unchanged — only the utils import path moves.