Skip to content

OverlayRect

OverlayRect = object

Defined in: overlayRect.ts:22

A locator’s on-screen box in CSS pixels of the recording viewport, ready to position an overlay over a live element.

The top-level placement fields (relativeTo, x, y, and exactly one of width/height) spread straight into an overlay config:

const rect = await overlayRect(page.locator('#save'))
const overlays = createOverlays({
ring: (p: { rect: OverlayRect }) => ({ element: <Ring />, ...p.rect }),
})
await overlays.ring({ rect }).start()

The full geometry (both axes) is also available under pixels, so a factory can pass it to a component that draws relative to the element (for example a circle around it).

optional height?: number

Defined in: overlayRect.ts:32

Height in CSS px. Present only when dimension: 'height' was requested.


pixels: object

Defined in: overlayRect.ts:38

The full box in CSS pixels (viewport-relative), after any margin and clamping to the viewport, carrying both axes. Equals the element’s boundingBox() when no margin is set.

height: number

width: number

x: number

y: number


relativeTo: "screen" | "recording"

Defined in: overlayRect.ts:24

Reference box for the placement fields. Defaults to 'recording'.


optional width?: number

Defined in: overlayRect.ts:30

Width in CSS px. Present unless dimension: 'height' was requested.


x: number

Defined in: overlayRect.ts:26

Left edge in CSS px of the recording viewport.


y: number

Defined in: overlayRect.ts:28

Top edge in CSS px of the recording viewport.