Skip to content

<XrWindow> ​

A panel with a handle bar. Grab the bar with a ray, a pinch or the mouse to move the window; it turns to face you. v-model:position keeps where it was put, so you can save and restore a layout.

Usage ​

vue
<XrWindow v-model:position="position" :width="440">
  <XrText variant="title">Drag the bar below</XrText>
</XrWindow>

Snapping to walls and tables ​

In a passthrough session on a Quest 3, snap makes the window stick to real surfaces from the room setup while it is carried: flat on a wall, facing into the room, or standing on a table, facing you. Pull it away to take it off.

vue
<XrWindow snap @snap="(label) => (stuckTo = label)">...</XrWindow>
<!-- or only some surfaces -->
<XrWindow :snap="['wall', 'window']" :snap-distance="0.2">...</XrWindow>

place fires on release with the window's world position and yaw.

Remembering where it was put ​

anchor="name" keeps the window where the user puts it down, across sessions and reloads: a persistent anchor on a Quest, so it stays on that wall even after a recentre; the saved pose elsewhere. Once placed it wins over position.

vue
<XrWindow anchor="notes" snap :position="[0.5, 1.3, -1]">...</XrWindow>
ts
// a "reset layout" button
useXrAnchor('notes').forget()

API ​

Props ​

PropTypeDefaultDescription
positionVec3[0, 1.4, -1]Where the window is, in scene metres. Use with v-model:position to keep where the user put it.
direction"row" | "column" | "row-reverse" | "column-reverse"'column'Main axis: children stacked (column) or side by side (row).
wrapbooleanWrap children onto more lines when they do not fit.
uiRecord<string, unknown>{}Escape hatch: raw uikit (@pmndrs/uikit) properties, merged last.
variant"surface" | "raised" | "sunken"'surface'Background: surface, raised or sunken (see XrPanel).
partsPartial<Record<"handle" | "bar", Record<string, unknown>>>Raw uikit properties per inner part, merged after the defaults: handle (the drag target under the window), bar (the bar drawn in it).
movablebooleantrueShow the handle and allow moving.
snapXrSnapTargetfalseStick to real surfaces while it is carried (passthrough on a Quest 3, from the room setup): true for walls and tables, or a list of plane labels (['wall', 'window', 'table']). On a wall it lies flat, facing into the room; on a table it stands on its bottom edge, facing you.
snapDistancenumber0.15How close, in metres, the window must come to a surface to stick to it.
distancenumberReading distance in metres. Scales the window to keep the same angular size.
gapSpaceValueSpace between children: a step on the theme's spacing scale (0..8), or "12px" in dmm.
paddingSpaceValueSpace inside the edges: a spacing step, or "12px".
align"flex-start" | "center" | "flex-end" | "stretch" | "baseline"Cross-axis alignment of the children (CSS align-items).
justify"flex-start" | "center" | "flex-end" | "space-between" | "space-around" | "space-evenly"Main-axis distribution of the children (CSS justify-content).
grownumberShare of the parent's free space to take (CSS flex-grow).
widthSizeWidth in dmm, a percentage of the parent ("50%"), or auto.
heightSizeHeight in dmm, a percentage of the parent, or auto.
anchorstringKeep the window where the user puts it down, under this name, across sessions and reloads: a persistent WebXR anchor on a Quest, the pose in the floor space elsewhere. It wins over position once placed. Set it once; useXrAnchor(name).forget() drops the saved place.
material"glass" | "metal" | "plastic"Lit material preset for the background (see XrPanel).

Events ​

EventPayloadDescription
placeplacement: { position: Vec3; yaw: number; }The window was put down: its world position and its rotation around the vertical axis, in radians.
snaplabel: string | nullThe window stuck to a surface (its label: wall, table...) or came off it (null), while carried.
update:positionposition: Vec3Where the window was put down (on release).

MIT License