---
title: Lay out and theme the panel
description: Float, dock, collapse or hide the devtools panel with data-position, data-mode, data-push and data-z-index, theme it light, dark or auto, override its --weft-* colour tokens, and drive it from the keyboard.
url: https://weftgo.dev/docs/observe/devtools/layout-and-theme/
type: how-to
sources:
  - 'W11-tag3, v0.20.2: weft/studio/web/src/panel/element.ts:5199-5216 (the narrow picker: status, steps and duration before the title or a replay''s lineage); weft/CHANGELOG.md:18 (0.20.2)'
  - 'W11-factcheck4, v0.20.2: weft/studio/web/src/panel/layout.ts:127-128 (an unknown stored tab opens raw when raw is set, else story)'
  - 'weft/studio/web/src/panel/layout.ts:51-52 (TABS story, request, waterfall, raw), 125-126 (an unknown stored tab opens story, or raw when raw is set); weft/studio/web/src/lib/keys.ts:112-124 (the panel''s / filters the list in view or the raw tree; Studio''s the runs list only); weft/studio/web/src/panel/element.ts:2888-2903 (the pill: text devtools, title ends — Alt+W, aria-label without it), 2438-2476 (not-reachable on a named loopback endpoint for the panel''s own dock) — v0.20.2'
  - 'weft/studio/README.md:1097-1108 (the activity pill: the count, unknown while running), 1111-1128 (the pill''s cost: priced figure, else tokens once finished, — while running, UX-H-31), 1199-1222 (the keyboard: PANEL_KEYMAP, the keys shared with Studio, [ ], s w q r, o); weft/studio/web/src/lib/keys.ts:122-150 (PANEL_KEYMAP) — v0.20.2'
  - 'weft/studio/README.md:1099-1107 (the activity pill: pulse, ● 3, aria-label, reduced motion)'
  - 'weft/studio/README.md:1111-1137 (Layout, plan D1: float, dock, pill, hidden, narrow, sheet, ⇆ and Alt+Shift+W, the attribute table)'
  - 'weft/studio/README.md:1139-1181 (Theme, plan D2: the order, ◐, data-theme-resolved, the palette, the tokens, the panel''s own tokens, color-scheme)'
  - 'weft/studio/README.md:1182-1197 (localStorage weft.devtools: the fields, placement written once placed, reset)'
  - weft/studio/README.md:1199-1221 (the keyboard table, SHORTCUTS)
  - weft/studio/README.md:1225-1254 (the renderer, plan D3; the ARIA table; the a11y budget)
  - 'weft/AGENTS.md:360-368 (block 7: layout D1, theme D2, renderer D3)'
  - weft/CHANGELOG.md:2111 (D3 incremental render and ARIA), 2130 (D2 theme), 2145 (D1 layout)
  - 'weft/studio/web/src/panel/layout.ts:22 (CYCLE), 25-51 (Layout), 54 (TABS), 57 (STORE_KEY weft.devtools), 60-69 (MIN_W 360, MIN_H 280, GAP 16, NARROW_W 640, SHEET_VW 480), 281-286 (initialLayout: 520×560 float, 460 dock, data-mode pill/hidden/float/dock), 103-196 (readStore: v 1 only), 79-85 (PLACE), 91-138 (writeStore), 142-226 (migrateDebug)'
  - 'weft/studio/web/src/panel/element.ts:525-529 (SHORTCUTS), 817-830 (observedAttributes: no data-mode), 2600-2602 (cycle), 2254-2275 (the ◐ button: set by the page, aria-disabled), 2880-2915 (the pill''s words)'
  - weft/studio/web/src/panel/theme.ts:59-80 (resolveTheme, nextTheme), 88-120 (ThemeWatch)
  - weft/studio/web/src/npm/index.ts:30 (Position), 40 (Mode), 68 (theme auto|light|dark)
  - weft/studio/web/src/lib/palette.ts:34-37, 55-58 (result, status-run, status-run-ink), 80, 99 (parked is status-parked); weft/studio/web/src/panel/styles.ts:24, 59
  - 'weft/studio/web/src/panel/element.ts:1077-1087 (data-open read on first connect), 2826-2836 (the bottom sheet pushes 70vh), 3204-3209 (the ⇆ label: layout: float | dock <side>)'
  - weft/studio/web/src/panel/layout.ts:215-220 (a top or bottom dock is viewport-wide)
  - weft/studio/web/src/panel/a11y.test.ts (axe over every mode in both themes), theme.test.ts (WCAG AA), layout.test.ts, keyed.test.ts
  - 'observed: Chromium (Playwright 1.62.0) against a scratch app embedding weft studio v0.17.0 (WEFT_DISCOVERY=off): the float at 520×560 bottom-right with z-index 2147483000; data-position=bottom-dock with data-push=true writes --weft-devtools-inset: 460px; padding-bottom: var(--weft-devtools-inset) on <html> and data-z-index=50 gives the dock z-index 50; data-mode=hidden draws nothing until Alt+W opens the float; Alt+Shift+W moves it to dock right; the pill reads devtools · 120→30 (aria-label weft devtools · 120→30, title weft devtools — Alt+W); <html class=dark> resolves dark, <html data-theme=light> wins over the class, data-theme=dark makes the ◐ button read theme: dark, set by the page; weft-devtools { --weft-bg: … } reaches the shadow tree; localStorage weft.devtools holds no placement until Alt+W, then mode, side, open, hidden, x, y, w, h, d'
---

# Lay out and theme the panel

The panel floats in a corner, docks to an edge of the page, collapses to a pill, or hides. Set where it starts with `data-position`, `data-open` and `data-mode` on its script tag (or `<weft-devtools>`, a `weft:*` meta tag or `mount()`); after that the user's own placement is remembered per origin. It is light or dark: `data-theme` decides, else the user's ◐ choice, else your page's theme. Every colour, radius and font is a `--weft-*` custom property your CSS can override.

Dock the panel on the right, open, and pad the page so nothing sits under it:

```html
<script type="module" src="/studio/panel.js" data-weft
        data-position="right-dock" data-open="true" data-push="true"></script>
```

[Install the devtools panel](https://weftgo.dev/docs/observe/devtools/install/#where-configuration-comes-from) lists every attribute, meta tag and `mount()` option, and the order they resolve in.

![The weft devtools panel docked on the right of an app page, its Story tab showing a step's tool calls and their errors](https://weftgo.dev/docs/_astro/panel-docked-right.light.BuHdPlbl.webp)

*data-position=&quot;right-dock&quot; data-open=&quot;true&quot;: the panel docked on the right, open on its story tab.*

## Layout

The panel has four modes:

| Mode | What you see | How it gets there |
|---|---|---|
| float | A 520×560 box in the bottom-right corner (or bottom-left), dragged by its header, resized from its corner between 360×280 and the viewport minus 16 px | the default when open |
| dock | Full height on the `left` or `right` edge, or full width on the `top` or `bottom`, 460 px across by default and resized along that edge | `data-position="right-dock"` and the other `-dock` values, or the header's `⇆` |
| pill | The collapsed button: the live dot and step count, and the current turn's cost: `· $0.0029` when Studio priced it, else its tokens once the run has finished, `· 300 in · 58 out` (an unpriced model, or a Studio without the `pricing` capability); `—` while it runs | collapsed, the default; `data-mode="pill"` |
| hidden | Nothing is drawn. The element, its [host API](https://weftgo.dev/docs/observe/devtools/host-api/) and its events keep working | `data-mode="hidden"`; `Alt+W` or `open()` brings it back |

The attributes that set the starting layout:

| Attribute | Values | Default | Effect |
|---|---|---|---|
| `data-position` | `bottom-right`, `bottom-left`, `right-dock`, `left-dock`, `top-dock`, `bottom-dock` | `bottom-right` | Where the dock starts: the float's corner, or the docked edge. Changed later, it moves the dock |
| `data-open` | `"true"` or an empty attribute | collapsed | Start expanded. Read once, when the element first connects: changing it later does nothing |
| `data-mode` | `float`, `dock`, `pill`, `hidden` | from the two above | The starting mode. `float` and `dock` start open; `pill` starts collapsed. Read once: changing it later does nothing |
| `data-push` | `"true"` | off | While docked and open, pad `<html>` on the docked side (below) |
| `data-z-index` | an integer | `--weft-z` on the element, else 2147483000 | The dock's and the pill's `z-index` |

The header's `⇆` button, labelled with the current layout (`layout: float`, `layout: dock right`), and `Alt+Shift+W` step through the layouts in one order: float, dock right, dock bottom, dock left, dock top. Under 640 px of panel width the turn list becomes a dropdown and the header's buttons wrap. Each option says the turn's status, steps and duration before its title or a replay's lineage (`● parked t3 · 1 step · 23 ms · Deploy…`), so a cut title never cuts them. The default 520 px float and the 460 px left or right dock are both that narrow, so they show the dropdown until you widen them; a top or bottom dock is as wide as the viewport. Under a 480 px viewport the panel is a full-width bottom sheet, at most 70 vh tall. The resize handles work with a pointer or touch only.

### Push the page aside

`data-push="true"` is the one write the panel makes to your document, and it is opt-in. While the panel is docked and open, it sets `--weft-devtools-inset` on `<html>` to the dock's size and pads that side by it. As the bottom sheet (under a 480 px viewport) it pads the bottom by `70vh`. Docked at the bottom with the default size, `<html>` carries:

```text
--weft-devtools-inset: 460px; padding-bottom: var(--weft-devtools-inset);
```

The inline padding it replaced, or one your page set meanwhile, is put back exactly when the dock closes, changes mode or disconnects. Padding does not move `position: fixed` or `sticky` elements, so keep a fixed composer clear with the same variable:

```css
.composer { bottom: var(--weft-devtools-inset, 0); }
```

Use `right`, `left` or `top` for those docks.

### Redraws keep your place

The panel patches its DOM in place instead of rebuilding it. A turn row is matched by its run id and a step card by its step ordinal, so while a turn streams only its running step's card changes. Focus, the caret, the panes' scroll and the `<details>` you opened stay where they were, because their nodes stay.

## The activity pill

The collapsed pill shows the conversation is busy without opening the panel. While the stream the panel already holds lists a run as running, the pill pulses and shows the run's live step count, `● 3`, with the `aria-label` `weft devtools · running, step 3`; its title adds ` — Alt+W`. The button's text always starts `devtools`. The count is the open tail's steps when that run is the turn the panel follows, else its row's; while that is unknown the pill reads `●` alone, `weft devtools · running`. The pulse is a CSS animation, off under `prefers-reduced-motion`. When the run ends, the next draw is the plain pill again, with the turn's cost or tokens.

![The collapsed devtools pill while a run runs: devtools ● 4](https://weftgo.dev/docs/_astro/panel-pill.light.iIPwEWdu.webp)

*The collapsed pill while a run is at its fourth step: devtools ● 4.*

## Theme

The panel resolves light or dark in this order:

1. **Explicit:** `data-theme="light"` or `"dark"` on the tag or element, `<meta name="weft:theme">`, or `mount({ theme })`. The header's `◐` button then reads `theme: dark, set by the page` and does nothing.
2. **Stored:** the user's `◐` choice. Each click steps auto → light → dark → auto; the choice is kept as `theme` in `localStorage["weft.devtools"]`, and auto clears it.
3. **Auto:** your page's `<html data-theme="dark|light">`, else `<html class="dark|light">`, else `<html>`'s computed `color-scheme` when it is exactly `dark` or `light`, then the system's `prefers-color-scheme`, else dark.

![The devtools panel as a float in the bottom-right corner, forced light over a page in the docs' theme: the turn's Story with step 0's lookup_order call and its result](https://weftgo.dev/docs/_astro/panel-float-light.light.CmfSJ_Bz.webp)

*data-mode=&quot;float&quot; data-theme=&quot;light&quot;: the float in the bottom-right corner stays light whatever the page's theme.*

`data-theme="auto"` is the default and means "use steps 2 and 3". A theme toggle on your page is followed live: one attributes-only `MutationObserver` on `<html>`'s `class` and `data-theme`, and one media-query listener, both removed on disconnect. The panel only reads `<html>`. The resolved theme is written to the element as `data-theme-resolved`, for your own CSS or tests.

### Override the colours

The palette is Studio's (`studio/web/src/lib/palette.ts`), and both themes meet WCAG AA contrast (4.5:1 for text, 3:1 for UI). Every colour, radius and font is a custom property on the panel's `:host`. A rule in your page's CSS beats the shadow tree's `:host`, in either theme:

```css
weft-devtools {
  --weft-accent: #0b6bcb;
  --weft-font-prose: Georgia, serif;
}
```

| Token | Used for |
|---|---|
| `--weft-bg`, `--weft-bg2`, `--weft-bg3` | panes; header, steps and footer; the selected row and fields |
| `--weft-fg`, `--weft-dim`, `--weft-faint`, `--weft-line` | text, secondary text, the faintest text, rules |
| `--weft-accent`, `--weft-on-accent` | the accent, and text on it |
| `--weft-warn`, `--weft-err`, `--weft-info`, `--weft-ok`, `--weft-parked` | status colours |
| `--weft-scrim`, `--weft-shadow` | the `?` overlay's backdrop, the float's shadow |
| `--weft-font`, `--weft-font-prose` | ids, JSON and numbers; a step's text, the prompt and notes (`system-ui, sans-serif`, no webfont) |
| `--weft-radius`, `--weft-radius-sm` | corner radii |
| `--weft-result` | a tool result's tone |
| `--weft-status-run`, `--weft-status-run-ink` | the running dot, the pill's pulse and border; the running word |
| `--weft-z` | the default `z-index`, below `data-z-index` |

`--weft-faint` (light), `--weft-scrim` and `--weft-shadow` are the panel's own; the rest equal a Studio variable (`--weft-parked` is Studio's `status-parked`). In light, `--weft-bg2` equals `--weft-bg`, so the header and steps differ from the panes by their rule line only. [Devtools panel reference](https://weftgo.dev/docs/reference/panel/#css-tokens) lists them with the panel's other attributes.

The "Studio not reachable" line sits in your page's flow: on a mount you made, and since 0.20.0 on the panel's own dock at a loopback endpoint you named. It takes your page's text colour, not a theme's.

## Remembered state

The panel keeps one JSON object per origin in `localStorage["weft.devtools"]`:

```json
{"v":1,"mode":"float","side":"right","open":true,"hidden":false,"x":864,"y":324,"w":520,"h":560,"d":460,"run":"s_01…-t3","theme":"","raw":false,"tab":"story","debug":false}
```

| Field | What it holds |
|---|---|
| `mode`, `side`, `open`, `hidden` | float or dock, the docked edge, expanded, hidden |
| `x`, `y`, `w`, `h` | the float's box, in px |
| `d` | the dock's size across its edge, in px |
| `run` | the last selected turn, by run id |
| `theme` | the `◐` choice: `light`, `dark`, or `""` for auto |
| `tab`, `raw` | the turn's open tab: `story`, `request`, `waterfall` or `raw` (a `timeline` stored before 0.20.0 opens `story`, or `raw` when `raw` is true); `raw` mirrors it |
| `debug` | the `?weft=debug` force-on switch ([Install](https://weftgo.dev/docs/observe/devtools/install/#the-script-tag)) |

The placement fields (`mode` through `d`) are written only once the user places the panel: a toggle, a drag, a resize or a re-dock. Until then your `data-*` attributes decide on every load; after it, the stored placement wins over them. A document with another `v` is ignored. Every read and write is guarded, so a private window forgets and the panel still works. To reset everything, including `debug`:

```js
localStorage.removeItem("weft.devtools")
```

## Keyboard

`Alt+W` is the only key the panel listens for on `window`. Every other key is heard on its shadow root, so it fires only while focus is inside the panel. A key typed into your page never reaches it, and keys typed into the panel's own fields are typing. `Alt+W` that opens the dock puts focus in it, so the other keys work at once. `?` inside the panel shows the list. Since 0.20.0 a key Studio also binds means the same there: `j` / `k`, `[` / `]`, `s` / `w` / `q` / `r`, `o` and `?` ([Studio's keyboard](https://weftgo.dev/docs/observe/studio/navigation/#keyboard)). `/` differs: here it filters the turn list or the raw tree, in Studio the runs list only.

| Key | Does |
|---|---|
| `Alt+W` | Toggle the dock from anywhere on the page, except while a text field has focus. `Ctrl+Shift+W` too, where the browser delivers it |
| `Alt+Shift+W` | Next layout: float, dock right, bottom, left, top |
| `Esc` | Close (the `?` list first). It is not stopped, so your page's own `Esc` handlers still run |
| `j` / `k` | Next / previous item of the list in focus (the turns) |
| `[` / `]` | Previous / next step (`⤢` carries it); `J` / `K` too |
| `s` / `w` / `q` / `r` | The story, waterfall, request or raw tab; again, back to the tab before it |
| `o` | Open the turn and step in Studio, in a new tab; `g s` too |
| `/` | Focus the filter: the raw tree's on the `raw` tab, else the turn list's |
| `←` / `→` | On the tabs: previous / next tab (`Home` / `End`: first / last) |
| `?` | The key list |
| `↓` / `↑` | On a turn row: move the list's one tab stop (`Enter` or a click selects) |
| `Tab` | In an open, focused float: wraps from the last control to the first (`Shift+Tab` back) |

The float is non-modal: it has no backdrop and the page stays live. Its `Tab` wrap is the panel's only focus trap, and `Esc` collapses the dock to leave it. Docked, as a pill or as the bottom sheet, the panel never traps focus.

## Accessibility

Every control has an ARIA role or label, the turn list has a roving tabindex, and weft's tests hold the panel to zero axe violations:

| Element | ARIA |
|---|---|
| The dock | `role="complementary"`, `aria-label="weft devtools"` |
| The turn list | `role="list"` (`aria-label="turns"`) of `role="listitem"` rows with a roving tabindex. The selected row has `aria-current="true"`, and each row's `aria-label` says it in words: `turn 3, parked, Refund order 4411, 1 step, 120 in 30 out, just now` |
| The running step's text | `aria-live="polite"` with `aria-busy="true"` while it streams: a screen reader waits rather than re-reading each draw |
| The step-end status | a visually hidden `role="status"` line, written once when the running step ends: `step N finished · n words` |
| The turn's tabs | `role="tablist"` (`aria-label="turn views"`) of `role="tab"` buttons with `aria-selected` and one `tabindex="0"`; the drawn panel is a `role="tabpanel"` |
| Expanders | `aria-expanded` on "how to scope", a subagent's summary and each raw tree node |
| Filters | `aria-label="filter turns"`, `"status"`, `"filter keys and values"` |
| Icon buttons | an `aria-label` on each: `⤢`, `⇆`, `◐`, `–`, `↺` and the pill. From 480 px of dock width, `⤢`, `⇆` and `◐` also show the words `Studio`, `layout` and `theme` |
| The switcher, the turn dropdown | `aria-label="conversation"`, `aria-label="turn"` |
| The experiment drawer | every field inside its `<label>`; selects labelled `model`, `thinking`, `side effects`, `engine`, `thread` |

weft's own test `studio/web/src/panel/a11y.test.ts` runs axe-core over the panel's shadow root in its modes, including (float open, docked right, the bottom sheet at 400 px, the pill, the `raw` tab with its tree open and filtered, the waterfall tab, the experiment drawer, the `?` overlay), in both themes, and fails on any violation. jsdom has no layout, so colour contrast is held by `theme.test.ts` instead. Contrast over your page, focus-ring visibility and real screen-reader announcements are checked by hand in a browser. axe-core is a dev dependency only; `panel.js` does not contain it.

## Complete example

A page that docks the panel at the bottom, pushes its own layout up, keeps a fixed composer clear, and recolours the accent. With the [devtools example](https://weftgo.dev/docs/observe/devtools/install/#complete-example) running, this is its page with the tag changed:

```html
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Order help</title>
  <style>
    .composer { position: fixed; left: 0; right: 0; bottom: var(--weft-devtools-inset, 0); }
    weft-devtools { --weft-accent: #0b6bcb; }
  </style>
</head>
<body>
  <h1>Order help</h1>
  <form class="composer"><input name="text" size="40"> <button>Ask</button></form>
  <script type="module" src="/studio/panel.js" data-weft
          data-position="bottom-dock" data-open="true" data-push="true"
          data-z-index="50" data-theme="dark"></script>
</body>
</html>
```

The dock opens across the bottom, dark, under any of your elements with a `z-index` above 50. The form stays above it. Once you drag, resize or re-dock it, your placement wins over these attributes on the next load, until `localStorage.removeItem("weft.devtools")`.

![The layout page's complete example: an Order help page with its composer kept above a dark panel docked along the bottom, the panel's accent recoloured blue, showing a turn's Story](https://weftgo.dev/docs/_astro/panel-dock-bottom-dark.light.D6XsBjLF.webp)

*This example's page: the dark dock across the bottom with the blue accent, the composer kept above it by --weft-devtools-inset.*

## Best practices & gotchas

- **Set the starting layout, then let the user own it.** After the first placement the stored layout wins over `data-position`, `data-open` and `data-mode` on every load; to see your attributes again, clear `localStorage["weft.devtools"]`. (Source: `studio/README.md:1191-1197`; `panel/layout.ts:79-97`)
- **`data-mode` and `data-open` are read once.** The element does not observe `data-mode`, and reads `data-open` only on its first connect; a framework that changes either after mount changes nothing. (Source: `panel/element.ts:412-425`, `904-914`)
- **Keep fixed elements clear with the variable, not the padding.** `data-push` pads `<html>`, which never moves `position: fixed` or `sticky` content; use `var(--weft-devtools-inset, 0)`. (Source: `studio/README.md:1135`)
- **Override tokens on the `weft-devtools` selector.** Your page's CSS cannot reach inside the shadow tree, but a rule on the host element sets its custom properties in both themes. (Source: `studio/README.md:1153-1160`)
- **Keyboard shortcuts need focus in the panel.** Only `Alt+W` works from the page; the rest fire inside the panel, so they never clash with your app's keys. (Source: `studio/README.md:1199-1207`; `panel/element.ts:496-499`)

## See also

- [Drive the panel from your page (host API and events)](https://weftgo.dev/docs/observe/devtools/host-api/)
- [Install the devtools panel](https://weftgo.dev/docs/observe/devtools/install/)
- [Read a run in the panel](https://weftgo.dev/docs/observe/devtools/reading-runs/)
- [Devtools panel reference](https://weftgo.dev/docs/reference/panel/)
- [What is the devtools panel?](https://weftgo.dev/docs/observe/devtools/overview/)
