# Interactive panels & overlays guide

> Choose the right interactive panel placement for your story, generate custom panels with zero coding using Studio's Copy AI prompt and Copy fix prompt buttons, and view the complete component reference.

Want to turn your chat into a rich, tactile world — with a live **relationship meter**, a clickable **clue card** inside a reply, an interactive **bookplate teaser** on your card's detail page, or a pop-up **sealed letter** over the chat? That's what **Components** do!

Even better: **you don't need to know HTML, CSS, or JavaScript to build one.** Studio has built-in **Copy AI prompt** and **Copy fix prompt** buttons so any AI assistant can design, code, and repair panels tailored to your story's exact variables and artwork.

Open **Components** in Studio to create and manage interactive panels for your work.

![Studio Components workspace where creators add interactive panels and choose where they appear in the story](/illustrations/studio-systems/studio-components.webp)

## Pick the right placement for your story moment

Each component can appear in one or more **placements** (and editing the component updates every placement automatically):

| Placement | Where players see it | Best used when… | Concrete story examples |
| :-- | :-- | :-- | :-- |
| **In reply** (`in-reply`) | Right inside a character's message when the AI brings it up | Something happens **at one specific moment** in the conversation | A _New Clue_ card with a "Note clue" button, a café receipt, a phone text screenshot, a tarot pull |
| **After reply** (`after-reply`) | Pinned beside or below the chat, staying live as variables change | The player should **always see their current status** at a glance | A relationship & mood meter, an RPG HP/gold bar, a detective clue board, a language study streak card |
| **Theater** (`theater`) | On your card's detail page before the player hits **Start** | You want an **unforgettable first impression** before turn 1 | A foggy windowpane you can wipe clear, an interactive cast preview, an animated harbor weather postcard |
| **Overlay** (`overlay`) | A focused layer over the reading area that opens on demand | The player needs **room to read or interact** without cluttering chat | A multi-page letter, an interactive town map, a 4-digit padlock puzzle, a full character dossier |

You can also add **Show when** conditions and turn ranges on reply placements so a panel only shows up in the chapters where it belongs (for example, hiding the clue board until Act 2 begins).

### Genre inspiration: Which panel should you build first?

- **Mystery / Detective:** Start with an **In reply** _Clue Card_ + a pinned **After reply** _Clue Board_ (we have ready-to-paste templates on the [Interactive panel ideas & templates](/en/creator/components-examples/) page!).
- **Romance / Relationship Drama:** Start with one pinned **After reply** _Relationship & Mood Card_ showing `trust` and current `mood`.
- **RPG / Fantasy Adventure:** Start with a pinned **After reply** _Party Status Bar_ (`hp`, `gold`, `location`) and add an **Overlay** _Inventory / Map_ later.
- **Cozy / Atmospheric Slice of Life:** Add a **Theater** postcard or interactive keepsake on your detail page (like our foggy _Study Window_ demo!).
- **Language Buddy / Tutor:** Add a pinned **After reply** _Streak & Vocab Card_ showing `level`, `topic`, and `streak`.

## Build a custom panel without writing code (5-step workflow)

1. **Declare your variables first:** Open **Work variables** and add everything your panel should show or update. **Important:** turn ON **Allow components to change** for any variable a player button should update directly (like lighting candles or crossing off a clue).
2. **Upload any artwork first:** If your panel needs icons, portraits, or textures, upload them under **Visuals & interactivity → Media** and give each asset a clear ID (like `cover` or `wax_seal`).
3. **Create the component & pick its placement:** Open **Components → + Add component**, choose its placement (**In reply**, **After reply**, **Theater**, or **Overlay**), and attach any media assets it will use.
4. **Click `Copy AI prompt` and add your creative wish:** Studio copies a complete brief containing your component's ID, placement, exact variable names/permissions, attached asset IDs, and LoreHat's rules. Paste it into ChatGPT, Claude, or Gemini, add 2–3 sentences describing the look and feel (borrow a starter below!), and paste the returned HTML straight back into Studio.
5. **Preview & polish with `Copy fix prompt`:** Check it live in **Preview chat** at both desktop and narrow phone widths. If Studio flags any issue in the editor, click **Copy fix prompt**, paste it into your AI, drop the updated HTML back in, and **re-test both desktop and phone views in Preview chat** to confirm the fix and layout both look right.

### Four plain-English wishes to paste after Studio's `Copy AI prompt`

Copy any of these right below Studio's copied prompt and customize the bracketed words:

**1. Cozy Romance Relationship Card (`after-reply`)**

```text
What I want this panel to look and feel like:
A warm, compact stationery card ("Notes on Elena") with soft cream paper tones in light mode and deep espresso tones in dark mode. Show a smooth progress bar for `trust` (0–100) and a pill badge for `mood` with a matching icon + label. No buttons needed — keep it slim and readable on a 320px phone screen.
```

**2. RPG Status & Quick-Action Strip (`after-reply`)**

```text
What I want this panel to look and feel like:
A crisp fantasy-journal status bar showing `hp`, `gold`, and current `location`, plus one "Check my satchel" button that opens my `inventory-overlay` overlay (using card.ui.open). Make sure icons + text both communicate status clearly, and match light/dark mode automatically.
```

**3. Interactive Sealed Letter (`overlay` with `wait` enabled)**

```text
What I want this panel to look and feel like:
An atmospheric parchment letter titled with the `title` prop and body text from the `body` prop, sealed with a wax-seal button labeled "Break the seal". Clicking the seal reveals the letter text with a gentle transition (respecting reduced motion), sets `seen_letter` to true, and shows a "Fold letter and continue" button that calls card.ui.done().
```

**4. Café Receipt / Polaroid Keepsake (`in-reply`)**

```text
What I want this panel to look and feel like:
A tilted vintage café receipt card inside the character's reply showing props `order`, `note`, and `total`. Add one button "Tuck into pocket" that emits action "keepsake.save" with { order, note } and switches its label to "Saved" once clicked.
```

## Five design habits players notice immediately

- **Looks great on phones too:** Design comfortably down to `320px` wide with zero horizontal scrolling and readable text (at least `14px`).
- **Comfortable buttons & accessible contrast:** Every clickable control should be a real `<button type="button">` (at least `44 × 44px`), readable in both light and dark themes (`system.colorScheme`), and never rely on color alone (always pair color with icons or words).
- **Gentle motion:** Respect players who prefer reduced motion (`@media (prefers-reduced-motion: reduce)`).
- **The story still stands on its own:** Panels elevate the experience, but the conversation should still make complete sense in plain text.
- **Never put spoilers in variables:** Everything passed to a panel is visible in the player's browser, so keep true plot secrets in **Characters → Character information** instead.

<a id="make-a-set-piece-the-story-depends-on"></a>

### Pausing a reply until the player interacts (`wait`)

On an **In reply** or **Overlay** placement, turning on **Wait** pauses the rest of the character's reply right at the panel until the player clicks a button (which calls `card.ui.done()`). This is fantastic for dramatic moments like opening a sealed envelope, flipping a tarot card, or unlocking a safe!

- **Players can never get stuck — three built-in safeguards:**
  1. **30-second timer while the tab is open:** Once the panel is ready and the browser tab is in the foreground, a 30-second timer begins (pausing if the player switches tabs). In regular player chats the timer runs quietly and reveals a **Continue** button after 30 seconds (and `Esc` / **Close** for overlays); Studio's preview also shows the remaining seconds so you can test it easily.
  2. **Interaction extends the timer once:** A real click or interaction inside the panel resets the 30-second timer once so players reading a multi-page letter aren't cut off mid-click.
  3. **Instant fallback on failure:** If a panel crashes or fails to load, LoreHat shows the **Continue** button **immediately**.
- **Make later branches bulletproof:** Test all three paths (completing the panel, clicking **Continue**, and a failure fallback). If the next scene depends on that moment (such as reading the letter), save a Yes/No variable like `seen_letter = true` in the same click as `card.ui.done()`, gate the next scene on `seen_letter == true`, and add a **fallback branch** in **Story** for players who clicked **Continue** instead. See [Craft branches, natural choices, fallbacks, and endings](/en/creator/story/#craft-branches-natural-choices-fallbacks-and-endings).

---

## Reference for AI assistants & component authors

Everything below is the exact technical contract enforced by LoreHat Studio and the chat sandbox. Studio's **Copy AI prompt** automatically links your AI to this section — and you can grab full copy-and-paste templates in [Interactive panel ideas & templates](/en/creator/components-examples/).

### 1. Format & Vue 3 template rules

- A component is **one self-contained HTML file** using the global **Vue 3.5.44** API (`Vue.createApp({...}).mount('#app')`). LoreHat provides `Vue` automatically — do not add a `<script>` tag for Vue and do not use `.vue` single-file syntax (`<script setup>`, `defineProps`, `<style scoped>`, `v-bind()` in CSS, or Vue 2 filters).
- Call `Vue.createApp({...})` **once** with inline options so Studio can statically inspect `props` and variable writes.
- Declare `in-reply` / `overlay` AI tag attributes statically in `props` (`String`, `Number`, `Boolean`, or JSON). Never use `placement` or `componentId` as prop names.
- Put `vars: card.vars`, `system: card.system`, and `assets: card.assets` in `data()` — all are reactive.
- **Data is data, never template:** Render props, variables, and system values with `{{ }}` or bindings (`:src`, `:style`). Never build `template:`, `innerHTML`, or `v-html` from them.
- Replace whole JSON objects when updating (`vars.clues = { ...vars.clues, [id]: title }`); mutating a nested property does not save.
- Keep all lasting state in `card.vars` (components scrolled out of view unmount and remount later).

### 2. Data a component receives

| Placement | `card.vars` | `props` | `card.system` |
| :-- | :-- | :-- | :-- |
| `after-reply` | All work variables (JSON as objects) | None | Yes |
| `in-reply` | All work variables | Attributes from the AI's `<Component componentId="..." />` tag | Yes |
| `theater` | Host-provided variables (may be empty) | None | Host-provided context |
| `overlay` | All work variables | AI tag attributes or `props` passed to `card.ui.open` (`{}` when passive) | Yes |

Available `card.system` fields:

| Field                                  | Meaning                                             |
| :------------------------------------- | :-------------------------------------------------- |
| `system.turn`                          | Player-message count                                |
| `system.isFirstTurn`                   | Whether the chat is on its first turn               |
| `system.scene.id`, `system.scene.name` | Current story node ID and title (when present)      |
| `system.scene.visited`                 | Array of visited story node IDs (including current) |
| `system.locale`                        | Player's interface language (e.g., `en`)            |
| `system.personaName`                   | Active persona name, when set                       |
| `system.colorScheme`                   | `'light'` or `'dark'`                               |
| `system.accentColor`                   | Current theme accent CSS color                      |

- Reserved names (`set`, `add`, `user_id`, `account`, `token`, `auth`, `credentials`, `chat_id`, `session_id`, `messages`, `history`, `system`) are never passed. Per-push data limit is 256 KiB; strings over 16,384 characters are dropped.

### 3. Allowed & disallowed capabilities

- **Allowed:** Vue 3.5.44 global API, inline `<script>` / `<style>`, DOM/CSS/SVG/Canvas, Google Fonts (`fonts.googleapis.com`), version-pinned CDN libraries from **jsDelivr**, **unpkg**, or **cdnjs** (exact version required; no `latest` or ranges), and declared card assets (`card.assets.<id>` for PNG, JPEG, WebP, GIF, SVG, MP3, OGG, WAV).
- **Not allowed:** `fetch`, `XMLHttpRequest`, `WebSocket`, external image/audio/font URLs (other than Google Fonts), `window.open`, pop-ups, navigation, child iframes, Web Workers, ES module `import`/`export`, `card.on`, `card.tool`, or `v-if` reading a loop variable on the same element as `v-for`.
- `localStorage` / `sessionStorage` live in memory only and reset on reload — store persistent state in `card.vars`.

### 4. Limits

| What                                              | Limit                                          |
| :------------------------------------------------ | :--------------------------------------------- |
| Components per work                               | 8                           |
| Source of one component                           | 65536 bytes (UTF-8)        |
| Source of all components combined                 | 262144 bytes (UTF-8)       |
| Assets per component                              | 8                      |
| Props per component                               | 12                       |
| AI attribute values per instance                  | 2000 characters total |
| Instances rendered per message                    | 2                   |
| Components mounted simultaneously                 | 6                    |
| Pinned (`after-reply`) components visible at once | 2                     |

### 5. The `window.card` API

| Call | Purpose |
| :-- | :-- |
| `card.vars`, `card.props`, `card.system`, `card.assets` | Reactive variables, read-only props, system context, and asset URL map |
| `card.onChange(({ vars, props, system }) => {})` | Subscribe to updates (rarely needed with Vue templates); returns unsubscribe function |
| `card.vars.set(id, value)`, `card.vars.add(id, by)` | Write a declared variable with **Allow components to change** enabled; `vars.x = v` is `set`, and standalone `+=`, `-=`, `++`, `--` statements on a fixed variable name rewrite to server-side `add` |
| `card.emit(action, payload?)` | Fires `component.action` for Rules and Scripts without sending a chat message (requires a real click/tap/key gesture) |
| `card.send(text)` | Sends `text` (1–8,000 chars) as the player's own message (requires a real gesture; at most once per gesture) |
| `card.scene.go`, `card.writingStyle.use`, `card.look.theme`, `card.look.slot`, `card.look.reset`, `card.prompt.note`, `card.suggest` | Story effects committed together with the user gesture (`card.prompt.rewrite`, `card.on`, `card.tool` are Scripts only) |
| `card.ui.done()` | Releases a `wait: true` reply pause (and closes an opened overlay) from a real user click/tap |
| `card.ui.open(componentId?, props?)` | Opens an `overlay` placement of the same work (`props.placement` picks a specific overlay placement); opening another overlay requires a real gesture, while an overlay may self-open once per minute after a reply finishes |
| `card.ui.setHeight(px)`, `card.ui.ready()`, `card.ui.reportError(err)` | Optional manual height control (auto-measured by default) and error reporting |

All async calls resolve to `{ ok: true }` or `{ ok: false, error: { code } }`:

- Common error codes: `rejected` (undeclared, not component-writable, or invalid type/size), `rate_limited` (>2/sec or >30/min), `loop_detected` (automatic non-gesture write budget of 3 reached — never write variables inside `watch` or `card.onChange`), `gesture_required`, `turn_in_progress`, `script_error`, `unavailable` (e.g. theater preview without an active chat), `overlay_hidden`, `queue_full`, `invalid_target`, `timeout`, `failed`.
- Synchronous throws: `card_call_requires_user_gesture` (calling privileged APIs outside a direct click/tap/keydown handler), `card_send_once_per_gesture`, `card_open_once_per_gesture`, or `TypeError` for invalid argument types.
- `action` names start with a lowercase letter, use `a–z`, `0–9`, `.`, `-`, and are at most 80 characters.

### 6. Minimal working template

```html
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <style>
      body {
        margin: 0;
        font:
          14px/1.5 system-ui,
          sans-serif;
      }
      .panel {
        padding: 12px;
        border-radius: 12px;
        background: #221c19;
        color: #f6ece2;
      }
      button {
        min-height: 44px;
        padding: 0 16px;
        font: inherit;
      }
      button:focus-visible {
        outline: 2px solid #e7b073;
        outline-offset: 2px;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <main class="panel">
        <p>Trust: <strong>{{ vars.trust }}</strong></p>
        <button type="button" @click="ask">Ask why</button>
      </main>
    </div>
    <script>
      const { createApp } = Vue;
      createApp({
        data() {
          return { vars: card.vars };
        },
        methods: {
          ask() {
            card.send('I ask why you still refuse to trust me.');
          },
        },
      }).mount('#app');
    </script>
  </body>
</html>
```

Next: browse ready-to-paste examples and remix prompts in [Interactive panel ideas & templates](/en/creator/components-examples/).
