# 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.

Example: Phone sized screen. A chat laid out at a true 390 px viewport, clear of the status bar and the home bar. Preview: https://chatcn.dev/preview/plain-screen-demo

## Installation

```bash
npx shadcn@latest add https://chatcn.dev/r/plain-screen.json
```

## Usage

```tsx
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.

```tsx
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.
- `FrameViewport` renders children at `viewport` and scales them from the top left inside a box `viewport.height * scale` tall. It sets `--chatcn-safe-top`, `-right`, `-bottom` and `-left` from `safe` and clips to `radius` without blurring the edge.
- `useFrameScript(steps, initial, { loop, paused, loopGap })` merges each step's `set` after its `wait`. It holds its place while paused, while the element given to `ref` is 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 |

Source: https://chatcn.dev/docs/components/plain-screen