Documentation Index
Fetch the complete documentation index at: https://mintlify.com/sveltejs/svelte/llms.txt
Use this file to discover all available pages before exploring further.
<svelte:window>, this element allows you to add listeners to events on document, such as visibilitychange, which don’t fire on window. It also lets you use attachments on document.
As with
<svelte:window>, this element may only appear at the top level of your component and must never be inside a block or element.Event Listeners
You can add any valid document event listener:Common document events
onvisibilitychange- Document visibility changesonfullscreenchange- Fullscreen mode changesonpointerlockchange- Pointer lock state changesonselectionchange- Text selection changesonkeydown- Key is pressed (anywhere in document)onkeyup- Key is releasedonclick- Click anywhere in document
Bindings
You can bind to the following document properties (all are readonly):The element that currently has focus.
The element currently displayed in fullscreen mode, or
null if no element is in fullscreen.The element that currently has the pointer locked, or
null if pointer is not locked.The visibility state of the document. Possible values:
"visible", "hidden".