> ## Documentation Index
> Fetch the complete documentation index at: https://docs.khanhng.com/llms.txt
> Use this file to discover all available pages before exploring further.

# UI capture plan format (capture.json)

> capture.json drives your real UI in Chromium and saves each state as a 2x image plus element boxes. Reference for every step type, with tips.

`capture.json` tells Demo Studio how to drive the real UI in Chromium. `ds.py capture` saves each **state** as a 2x PNG (`snap/<name>.png`) and the **boxes** of the elements to lift, zoom or click (`snap/meta.json`, in page CSS pixels). Capture every state the story needs, in order, as a real user would.

```json capture.json theme={null}
{
  "base": "inputs/ui/",
  "viewport": {"width": 1600, "height": 900}, "scale": 2,
  "inject_fonts": false,
  "hide": [".toast"],
  "steps": [
    {"goto": "new-claim.html"},
    {"fill": ["#orderNumber", "ORD-84510"]},
    {"snap": "form_filled"},
    {"boxes": {"state": "form_filled", "map": {"submit": "#claimForm button[type=submit]"}}}
  ]
}
```

* `base`: relative to the project folder, or a URL.
* `inject_fonts`: `true` forces the bundled Inter font into the UI.
* `hide`: prototype-only overlays to hide.

## Step types

Each step is an object with one key, plus an optional `"settle": ms` for `snap`.

| Step | Value |
| - | - |
| `goto` | Page path (relative to base) or URL |
| `reload`, `clear_storage`, `prep` | `true`. Use `prep` after a click that navigates: it waits for load and re-applies fonts and hiding |
| `click`, `hover` | CSS selector, or `{"text": "New claim", "sel": "a,button"}` |
| `fill` | `[selector, text]` |
| `select` | `[selector, "Visible label"]` or `[selector, {"value": "accept-ai"}]` |
| `files` | `[selector, ["fx/receipt.pdf"]]` (paths relative to base) |
| `press` | `[selector, "Enter"]` |
| `wait`, `mark`, `wait_until` | Milliseconds. `mark` starts a timer and `wait_until` waits until N ms after it, for the product's own timers |
| `viewport`, `fit_height`, `scroll_top`, `mouse_away` | Resize; grow to the page height; scroll; move the pointer out of the way |
| `style`, `eval` | CSS to add; a JavaScript expression to run in the page |
| `snap` | State name: takes the snapshot |
| `type_steps` | `{"sel", "text", "every": 3, "prefix": "note"}`: types the text and saves `note01` to `noteNN` for typing animations |
| `box`, `boxes`, `box_all` | `{"state", "key", "sel"}`; `{"state", "map": {key: sel}}`; `{"state", "sel", "prefix"}` (keys `prefix0` to `n`) |
| `box_text` | `{"state", "key", "sel", "re", "max_len", "closest"}`: the smallest element whose text matches |
| `spinner` | `{"state", "anchor_sel", "offset": [x, y], "size": 18, "n": 12, "period": 0.85, "phase_css": "…{delay}…"}`: 12 phase crops of a CSS spinner, so the video plays the product's real spinner |
| `script` | An async JavaScript body with `pg` (the Playwright page) and `api` (`snap`, `box`, `el`, `meta`) for anything unusual |

## Tips

* Snapshot the **real timing states**: `mark` before the action, then `wait_until` the product's own timers. If the video shows them faster, the scene spec discloses it as time-compressed.
* Record boxes **in the state you'll show**. Layouts move when panels open.
* For tall pages, add `fit_height`. One snapshot then covers the whole page, and scenes crop regions of it.
* Check `snap/meta.json`: `missing` must be empty.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.