use-screen-details
Snapshot a ScreenDetailed into a plain object.
| Package | @vizejs/composable/use-screen-details |
| Own the source | vize lib pull composable:use-screen-details |
| Runtime exports | useScreenDetails, placeWindow, snapshotScreen |
| Gzip budget | 2816 B |
Minimal setup
Use a Vue 3.5+ project with Vue SFC compilation configured (see Vite+ integration).
vp install @vizejs/composable
Import the entry directly. Call lifecycle-bound utilities inside <script setup> so cleanup follows the component scope; consult the runtime contract for this entry's SSR and hydration behavior.
import { useScreenDetails, placeWindow, snapshotScreen } from "@vizejs/composable/use-screen-details";
Try it
Find a second screen
Discover connected screens to open speaker notes on another display.
What to observe: Find screens asks for permission where Window Management exists and lists the screens.
openOnScreen opens a window positioned on a chosen screen. Every example renders a neutral message until it mounts, so server and client markup match, and then explains what to do when the browser lacks the API.
Compare the initial and interacted states


Copy the example
Save this complete SFC in your Vue project. Its public imports and source are the same ones executed in the preview.
<script setup lang="ts">
import { useMounted } from "@vizejs/composable/use-mounted";
import { useScreenDetails } from "@vizejs/composable/use-screen-details";
const mounted = useMounted();
const { supported, isExtended, screens, request } = useScreenDetails();
</script>
<template>
<div class="composable-example">
<p>Open speaker notes on a second screen when one is connected.</p>
<button type="button" :disabled="!mounted || !supported" @click="() => request()">
Find screens
</button>
<ul aria-label="Screens">
<li v-for="(screen, index) in screens" :key="screen.label || index">
{{ screen.label || `Screen ${index + 1}` }}
</li>
</ul>
<output aria-live="polite">{{
!mounted
? "Checking browser support…"
: !supported
? "Window Management is not available; open the notes in a new tab."
: isExtended
? "A second screen is connected."
: "One screen detected."
}}</output>
</div>
</template>
Runtime contract
| Utility | Category | Stability | SSR | Hydration | Cleanup | Targets | Host globals | Uses |
|---|---|---|---|---|---|---|---|---|
useScreenDetails |
capability | experimental | deterministic-fallback | caller-managed | caller, reactive-scope | web, desktop | window |
tryOnScopeDispose |
placeWindow |
system | experimental | safe | stable | none | web, server, worker, native, desktop, terminal | — | — |
snapshotScreen |
system | experimental | safe | stable | none | web, server, worker, native, desktop, terminal | — | — |
API
snapshotScreen
Snapshot a ScreenDetailed into a plain object.
function snapshotScreen(screen: ScreenSnapshot): ScreenSnapshot
placeWindow
Compute absolute window geometry inside a screen's available area. Sizes are clamped to the available area; omitted offsets center the window.
function placeWindow( screen: ScreenArea, placement: WindowPlacementOptions = {}, ): WindowPlacement
useScreenDetails
Enumerate and target multiple screens with the Window Management API. isExtended is live from window.screen. request() asks for the window-management permission; once granted, screens and currentScreen stay current through screenschange, currentscreenchange, and per-screen change events. openOnScreen opens a window placed with placeWindow. Listeners are removed when the owning reactive scope stops; outside a scope call stop(). Server rendering: nothing is requested, supported and isExtended are false and screens is empty.
function useScreenDetails(options: UseScreenDetailsOptions = {}): ScreenDetailsControls
const { request, screens, openOnScreen } = useScreenDetails();
await request();
const external = screens.value.find((screen) => !screen.isPrimary);
if (external) openOnScreen("/slides", external, { features: "popup" });
Types
ScreenArea
Available (work) area of a screen in multi-screen coordinates.
| Member | Type | Description |
|---|---|---|
availLeft |
number |
Left edge of the available area. |
availTop |
number |
Top edge of the available area. |
availWidth |
number |
Width of the available area. |
availHeight |
number |
Height of the available area. |
ScreenSnapshot
Plain snapshot of a ScreenDetailed.
| Member | Type | Description |
|---|---|---|
availLeft |
number |
Left edge of the available area. |
availTop |
number |
Top edge of the available area. |
availWidth |
number |
Width of the available area. |
availHeight |
number |
Height of the available area. |
label |
string |
Human-readable label, possibly empty. |
left |
number |
Left edge in multi-screen coordinates. |
top |
number |
Top edge in multi-screen coordinates. |
width |
number |
Full width. |
height |
number |
Full height. |
devicePixelRatio |
number |
Device pixel ratio. |
colorDepth |
number |
Color depth in bits. |
isPrimary |
boolean |
Whether this is the primary screen. |
isInternal |
boolean |
Whether this screen is built into the device. |
ScreenDetailedLike
Minimal ScreenDetailed.
| Member | Type | Description |
|---|---|---|
availLeft |
number |
Left edge of the available area. |
availTop |
number |
Top edge of the available area. |
availWidth |
number |
Width of the available area. |
availHeight |
number |
Height of the available area. |
label |
string |
Human-readable label, possibly empty. |
left |
number |
Left edge in multi-screen coordinates. |
top |
number |
Top edge in multi-screen coordinates. |
width |
number |
Full width. |
height |
number |
Full height. |
devicePixelRatio |
number |
Device pixel ratio. |
colorDepth |
number |
Color depth in bits. |
isPrimary |
boolean |
Whether this is the primary screen. |
isInternal |
boolean |
Whether this screen is built into the device. |
ScreenDetailsLike
Minimal ScreenDetails.
| Member | Type | Description |
|---|---|---|
screens |
readonly ScreenDetailedLike[] |
Every connected screen. |
currentScreen |
ScreenDetailedLike |
Screen hosting the current window. |
ScreenDetailsHost
Capabilities used by useScreenDetails.
| Member | Type | Description |
|---|---|---|
getScreenDetails? |
() => Promise<ScreenDetailsLike> |
Window Management entry point (permission-gated). |
screen? |
object | null |
window.screen. Its isExtended flag is read and, when it is an EventTarget, its change event refreshes the flag. |
open? |
(url: string, target: string, features: string) => Window | null |
window.open, used by openOnScreen. |
UseScreenDetailsOptions
Options for useScreenDetails.
| Member | Type | Description |
|---|---|---|
host? |
MaybeRefOrGetter<ScreenDetailsHost | null | undefined> |
Window Management capability for alternate runtimes and tests. |
WindowPlacementOptions
Desired window geometry relative to a screen's available area.
| Member | Type | Description |
|---|---|---|
width? |
number |
Window width, clamped to the available width. |
height? |
number |
Window height, clamped to the available height. |
left? |
number |
Offset from the available area's left edge. |
top? |
number |
Offset from the available area's top edge. |
WindowPlacement
Absolute window geometry for window.open features or moveTo/resizeTo.
| Member | Type | Description |
|---|---|---|
left |
number |
Absolute left. |
top |
number |
Absolute top. |
width |
number |
Width. |
height |
number |
Height. |
OpenOnScreenOptions
Options of ScreenDetailsControls.openOnScreen.
| Member | Type | Description |
|---|---|---|
width? |
number |
Window width, clamped to the available width. |
height? |
number |
Window height, clamped to the available height. |
left? |
number |
Offset from the available area's left edge. |
top? |
number |
Offset from the available area's top edge. |
target? |
string |
Browsing context name. |
features? |
string |
Extra comma-separated window features, for example "popup". |
ScreenDetailsControls
Reactive state and actions returned by useScreenDetails.
| Member | Type | Description |
|---|---|---|
supported |
ComputedRef<boolean> |
Whether the Window Management API is available. |
isExtended |
Readonly<Ref<boolean>> |
Whether the window spans a multi-screen setup (screen.isExtended). |
screens |
Readonly<ShallowRef<readonly ScreenSnapshot[]>> |
Snapshots of every screen, empty until request succeeds. |
currentScreen |
Readonly<ShallowRef<ScreenSnapshot | undefined>> |
Snapshot of the current screen, once granted. |
pending |
Readonly<Ref<boolean>> |
Whether request is in progress. |
error |
Readonly<ShallowRef<unknown>> |
Most recent request failure, cleared on success. |
request |
() => Promise<ScreenDetailsResult> |
Request screen details (prompts for the window-management permission). |
openOnScreen |
( url: string, screen: ScreenArea, options?: OpenOnScreenOptions, ) => Window | null |
Open a window placed on screen. |
stop |
() => void |
Remove every listener. Idempotent. |