<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
| Prop | Type | Default | Description |
|---|---|---|---|
position | Vec3 | [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). |
wrap | boolean | Wrap children onto more lines when they do not fit. | |
ui | Record<string, unknown> | {} | Escape hatch: raw uikit (@pmndrs/uikit) properties, merged last. |
variant | "surface" | "raised" | "sunken" | 'surface' | Background: surface, raised or sunken (see XrPanel). |
parts | Partial<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). | |
movable | boolean | true | Show the handle and allow moving. |
snap | XrSnapTarget | false | Stick 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. |
snapDistance | number | 0.15 | How close, in metres, the window must come to a surface to stick to it. |
distance | number | Reading distance in metres. Scales the window to keep the same angular size. | |
gap | SpaceValue | Space between children: a step on the theme's spacing scale (0..8), or "12px" in dmm. | |
padding | SpaceValue | Space 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). | |
grow | number | Share of the parent's free space to take (CSS flex-grow). | |
width | Size | Width in dmm, a percentage of the parent ("50%"), or auto. | |
height | Size | Height in dmm, a percentage of the parent, or auto. | |
anchor | string | Keep 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
| Event | Payload | Description |
|---|---|---|
place | placement: { position: Vec3; yaw: number; } | The window was put down: its world position and its rotation around the vertical axis, in radians. |
snap | label: string | null | The window stuck to a surface (its label: wall, table...) or came off it (null), while carried. |
update:position | position: Vec3 | Where the window was put down (on release). |