# Fold frame

A book style foldable with two live displays. Shut, the small cover display; open, one wide display with two apps side by side; standing like a book; and the back with its camera plateau. It folds between them in real 3D on a spring.

> chatcn Pro: needs a Pro license (https://chatcn.dev/pro). Install from the `@chatcn-pro` registry with your license token; setup at https://chatcn.dev/docs/chatcn-pro.

Example: Fold frame. A book style foldable: the cover display says the brief is ready, then it unfolds into the chat and the brief side by side, stands like a book and turns round. Preview: https://chatcn.dev/preview/fold-frame-demo

## Installation

```bash
npx shadcn@latest add @chatcn-pro/fold-frame
```

## Usage

```tsx
import { FoldFrame } from "@/components/ui/chatcn/pro/fold-frame"

<FoldFrame
  width={720}
  posture={open ? "open" : "closed"}
  cover={<LockScreen />}
  start={<Chat />}
  end={<Artifact />}
/>
```

Each screen half renders at a 472 px wide viewport and scales with the frame, so one layout fits the cover display and either half of the inner one. `start` and `end` are two apps side by side; `inner` is one app across both halves at 944 px. The safe area insets reach your content as `--chatcn-safe-top`, `-right`, `-bottom` and `-left`: the inner status bar sits in the top corner, the cover's around the camera hole.

Change `posture` and the device folds on a critically damped spring: the half on the table stays put while the other swings up toward the camera, darkening as it turns away from the light, and the spine grows out of the hinge as it shuts. The cover display wakes as it comes round. Set `angle`, 0 shut to 180 flat, to drive the hinge yourself from a scroll position or a slider.

`width` is the open device. Shut, the frame is about half as wide and just as tall, so the same width keeps the same scale in every posture. The frame takes the footprint of its posture; put it in a box the size of the open device when the posture changes in place.

## Examples

### Every posture

Example: Fold frame postures. Shut, open, standing, the back, halfway through a fold, one app across both halves, the finishes and phone width. Preview: https://chatcn.dev/preview/fold-frame-postures

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `posture` | `"closed" | "open" | "stand" | "back"` | Default `open` |
| `angle` | `number` | 0 shut to 180 flat. Follows at once, no spring |
| `width` | `number` | The open device, in px. Default 720 |
| `cover` | `ReactNode` | The cover display, 472 px wide |
| `start`, `end` | `ReactNode` | The two halves of the inner display, 472 px each |
| `inner` | `ReactNode` | One app across both halves, 944 px. Wins over `start` and `end` |
| `finish` | `"auto" | "silver" | "graphite" | "black" | "white"` | Default `auto`: silver on light, graphite on dark |
| `statusBar`, `time` | `boolean`, `string` | Default true and `10:24` |
| `homeIndicator`, `crease`, `buttons` | `boolean` | Default true |
| `shading`, `shadow`, `glare` | `boolean` | Default true, true, false |
| `screenClassName`, `coverClassName` | `string` | For a background or `dark` on either display |
| `onSettle` | `(posture) => void` | When a fold comes to rest |

## Accessibility

- The display that is not in use is `inert`: shut, the inner halves; open or standing, the cover. Focus and screen readers only reach what is on screen.
- While `inner` spans both halves, the start half shows an inert, hidden copy during a fold; the live app is the one on the end half.
- The hardware is decorative and hidden from assistive technology. The frame adds no controls of its own.
- Reduced motion: the device does not fold. It cuts to the new posture with a 150 ms fade.
- Under `forced-colors` the body and both displays keep a system outline.

Source: https://chatcn.dev/docs/components/fold-frame