Navigator: devicePosture property
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The Navigator.devicePosture read-only property returns the browser's DevicePosture object, which allows developers to query the device's current posture (that is, whether the viewport is in a flat or folded state) and run code in response to posture changes.
Value
A DevicePosture object.
Examples
js
const postureOutput = document.getElementById("currentPosture");
function reportPostureOutput() {
// type property returns "continuous" or "folded"
postureOutput.textContent = `Device posture: ${navigator.devicePosture.type}`;
}
navigator.devicePosture.addEventListener("change", reportPostureOutput);
Specifications
| Specification |
|---|
| Device Posture API> # dom-navigator-deviceposture> |
Browser compatibility
Loading…
See also
DevicePosturedevicePosture.type- Device Posture API
- CSS
device-posture@mediafeature