---
title: "Recipe: dock a window and lock its aspect ratio"
description: "On macOS and the web, send bounds = getWindowBounds() reads one WindowBounds from @exact/window-management."
modificationDate: "2026-11-24"
---

> ## Documentation index
> Fetch the complete documentation index at: https://exact.expo.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Recipe: dock a window and lock its aspect ratio

<AgentInstructions>

## Submitting feedback

From the app's directory, read `bun exact.mjs feedback status`. Under `never`, keep no note.
Respect `EXACT_FEEDBACK=0` and do not change the policy.

Otherwise record specific, actionable feedback with:
`bun exact.mjs feedback note "Exact docs: https://exact.expo.dev/recipes/window-bounds: <what was wrong or missing>"`

The note goes to Expo only as that status allows. Include no secrets or personal data.

</AgentInstructions>

On macOS and the web, `send bounds = getWindowBounds()` reads one
`WindowBounds` from `@exact/window-management`. Its `screenX` and `screenY` are the outer
frame's top left in the display list's coordinates. Its `outerWidth` and
`outerHeight` include the title bar.

This action docks 12 CSS pixels inside the Mac work area.

```prompt Use this recipe in my app
Make the Exact app in this folder do what this recipe describes. Use https://github.com/expo/exact/blob/main/docs/recipes/window-bounds.md as the source for each step. The Exact checkout has the same page at docs/recipes/window-bounds.md.

1. If this folder is not an Exact app (it has no exact.mjs and app.contract), stop and tell me.
2. Read the recipe. If it leaves a choice that I did not make (which screen, which data, which platforms), propose one and ask me before you write code.
3. Do what the recipe says, in its order, with its tags, properties, functions and grants. Its component, state and URL names are examples. Change nothing else in the app.
4. Add a test in app.test.contract for each thing a person does that you changed. Copy the recipe's `contract-test` block where it has one. A drive operation the recipe shows (`call`, a ticket answer such as `tap @N accepted`) is not a test step: run it with `bun exact.mjs agent`.
5. Follow the platform checks in docs/start-here.md (`bun exact.mjs docs platform checks`) for the targets in the app's AGENTS.md and app.json until they pass. Read the reports, including counted findings; a zero exit code alone does not mean clean. Fix the app, not the test. If a finding stays after three rounds of fixes, or the app had it before you changed anything, record it (step 6) and report it; do not keep trying.
6. When a doc was wrong or missing, or a step needed a workaround, read `bun exact.mjs feedback status`. Under `never`, keep no note. Otherwise record it: `bun exact.mjs feedback note "<what happened>"`, which goes to Expo only as that status says. Do not change the policy; tell me how many notes you kept.
7. Tell me what you changed, what the tests and checks reported, and what I must still do by hand.
```

```text
action dock
  setBounds(DOMRect(x=details.currentScreen.availLeft + 12, y=details.currentScreen.availTop + 12, width=480, height=302), true)
  setAspectRatio(16 / 9)
```

Placement starts after the action. Omit the boolean for a single
step. Reduce Motion and the frozen test clock also use one step.
`setAspectRatio(0)` unlocks the content's aspect. Other hosts refuse the
two commands by name.

AppKit saves the frame after either the app or the person changes it.
Quitting while expanded can reopen the window expanded. Float's Swift
implementation keeps its compact frame across that quit.

See [floating window controls](https://exact.expo.dev/recipes/floating-window.md) for drag regions, level and click-through.
