Plain screen
A flat phone sized screen for demos: children lay out at a true 393 by 852 viewport, scale to fit, and read the status bar and home bar insets as CSS variables.
On this page
Installation
Usage
import { PlainScreen } from "@/components/ui/chatcn/plain-screen"
<PlainScreen width={320}>
<div className="h-full pt-[var(--chatcn-safe-top)] pb-[var(--chatcn-safe-bottom)]">
<Conversation>{messages}</Conversation>
</div>
</PlainScreen>Children are real DOM laid out at the viewport size, then scaled as one piece, so text stays sharp and a 390 px layout is a 390 px layout at any rendered width. A width in px may scale above 1; any other width caps at the viewport. The page flow follows the rendered height from the first paint, so nothing below the frame moves when it measures.
The screen is flat on purpose: a 48 px corner, a thin dark bezel and the status bar (statusBar={false} hides it). The Pro phone frame adds the body, buttons, the cutout, materials and tilt.
Build your own frame
Every free frame sits on chatcn-frames, which ships with this item. FrameLite is the shell; useFitScale and FrameViewport are its two halves if you need your own markup; useFrameScript plays a timed story for a demo.
import { FrameLite, useFrameScript } from "@/lib/chatcn-frames"
const steps = [
{ wait: 800, set: { open: true } },
{ wait: 1200, set: { answered: true } },
] as const
function Demo() {
const { state, ref } = useFrameScript(steps, { open: false, answered: false }, { loop: true })
return (
<FrameLite ref={ref} viewport={{ width: 1280, height: 800 }} radius={12}>
<MyApp open={state.open} answered={state.answered} />
</FrameLite>
)
}useFitScale(ref, width)returns box width /width, measured before the first paint and flushed in the same frame on resize. It returns 0 until measured.FrameViewportrenders children atviewportand scales them from the top left inside a boxviewport.height * scaletall. It sets--chatcn-safe-top,-right,-bottomand-leftfromsafeand clips toradiuswithout blurring the edge.useFrameScript(steps, initial, { loop, paused, loopGap })merges each step'ssetafter itswait. It holds its place while paused, while the element given torefis off screen and while the tab is hidden. Under reduced motion the story still plays; components cut their transitions.
Props
| Prop | Type | Notes |
|---|---|---|
viewport | { width, height } | Default 393 by 852 |
width | number | string | Default 100%, capped at the viewport |
bezel | none | hairline | thin | Default thin |
radius | number | Viewport px, default 48 |
safe | { top, right, bottom, left } | Default 59 top, 34 bottom |
statusBar | boolean | ReactNode | Default true: 9:41, signal, Wi-Fi, battery |
| Home indicator | Drawn 8 px above the bottom edge whenever safe.bottom is set | |
screenClassName | string | Classes for the screen box |