navigator.devicePosture returns a DevicePosture object for foldable-aware UIs. Learn type (continuous / folded), change events, CSS device-posture, five examples, and try-it labs.
01
Kind
Read-only property
02
Returns
DevicePosture
03
Status
Experimental
04
Flat
continuous
05
Folded
folded
06
Updates
change event
Fundamentals
Introduction
Foldable phones and dual-screen devices can bend into book or laptop shapes. Layouts that look great flat may need a different split when the screen is folded.
The Device Posture API exposes that physical state through navigator.devicePosture. You read .type and can listen for change when the user folds or unfolds the device.
💡
Progressive enhancement
Ship a normal responsive layout first. Use posture only to refine foldable experiences when the API is present.
Concept
Understanding the devicePosture Property
Think of navigator.devicePosture as a live sensor for “is the screen flat or folded?” You do not assign to it — you read type and subscribe to events.
type: "folded" — book / laptop fold posture on foldables.
change — event when posture updates.
CSS — @media (device-posture: continuous | folded) when supported.
Foundation
📝 Syntax
General form of the property:
JavaScript
navigator.devicePosture
Value
A DevicePosture object with a type string and a change event.
Common patterns
JavaScript
// MDN-style report + listener:
function reportPostureOutput() {
console.log(`Device posture: ${navigator.devicePosture.type}`);
}
if ("devicePosture" in navigator) {
reportPostureOutput();
navigator.devicePosture.addEventListener("change", reportPostureOutput);
}
Cheat Sheet
⚡ Quick Reference
Goal
Code
Get DevicePosture
navigator.devicePosture
Detect API
"devicePosture" in navigator
Current posture
navigator.devicePosture.type
Listen for updates
devicePosture.addEventListener("change", fn)
Flat?
type === "continuous"
Folded?
type === "folded"
Snapshot
🔍 At a Glance
Four facts to remember about navigator.devicePosture.
Returns
DevicePosture
API object
Status
experimental
Not Baseline
Types
continuous | folded
Posture strings
Best for
foldables
Optional UX
Compare
📋 JS devicePosture vs CSS Media
navigator.devicePosture
@media (device-posture: …)
Language
JavaScript
CSS
Best for
Logic, analytics, dynamic components
Layout / spacing / visibility
Live updates
change event
Media query re-evaluation
Support
Experimental / limited
Same API family — still limited
Use together?
Yes — CSS for styles, JS for behavior when both exist
Hands-On
Examples Gallery
Examples follow MDN Device Posture / navigator.devicePosture patterns. Prefer Try It Yourself on a supporting / emulated foldable. Use View Output for expected messaging.
layout: standard
(or split-panels when type is folded)
How It Works
Use split-panels for dual-pane reading/chat UIs when folded; otherwise keep your normal layout.
Example 5 — Listen for change
Report the initial posture and updates when the user folds/unfolds.
JavaScript
const lines = [];
function report(label) {
if (!("devicePosture" in navigator)) {
lines.push(label + ": unsupported");
return;
}
lines.push(label + ": " + navigator.devicePosture.type);
}
report("initial");
if ("devicePosture" in navigator) {
navigator.devicePosture.addEventListener("change", function () {
report("changed");
console.log(lines.join("\n"));
});
}
console.log(lines.join("\n"));
// Fold/unfold (or use foldable emulation) to see "changed" in Try It
initial: continuous
(then "changed: …" when posture updates)
How It Works
MDN notes some DevTools foldable emulations only simulate fully open/closed flat states, so you may stay on continuous until real folded hardware (or fuller emulation) is available.
Applications
🚀 Common Use Cases
Dual-pane apps — list + detail when folded, single stack when flat.
Reading / chat — keep conversation on one side of the fold.
Video + controls — put player above the hinge and controls below.
CSS + JS combo — style with device-posture media; orchestrate with JS.
Progressive enhancement — ignore posture when the API is missing.
🧠 How navigator.devicePosture Works
1
Feature-detect
Check "devicePosture" in navigator.
Detect
2
Read DevicePosture.type
Get continuous or folded.
Type
3
Adapt the UI
Switch layouts or CSS classes for fold vs flat.
Adapt
4
✅
Listen for change
Update again when the user folds or unfolds.
Important
📝 Notes
Experimental and not Baseline — support is limited.
Not Deprecated or Non-standard on MDN.
Most non-foldable devices report continuous when the API exists.
navigator.devicePosture (Device Posture API) is Experimental and not Baseline. Availability is limited and may require experimental flags or foldable hardware. Always feature-detect.
✓ Experimental · Not Baseline
Navigator.devicePosture
Use continuous/folded as progressive enhancement for foldable layouts — never as a hard requirement.
LimitedNot Baseline
Google ChromeExperimental / limited — check flags & foldable support
Limited
Microsoft EdgeChromium-based — follow Chrome Device Posture status
Limited
OperaChromium-based — check current compat
Limited
Mozilla FirefoxNot available for typical web content
Unavailable
Apple SafariNot available for typical web content
Unavailable
devicePostureLimited
Bottom line: Detect devicePosture, adapt when present, and keep a solid responsive default for everyone else.
Wrap Up
Conclusion
navigator.devicePosture is the Device Posture API entry point for foldable UIs. Feature-detect it, read type, listen for change, and keep a normal responsive layout when the API is missing.
It is a read-only Navigator property that returns a DevicePosture object so you can read whether the viewport is continuous (flat) or folded, and listen for posture changes on foldable devices.
Yes. MDN marks it Experimental and not Baseline. Support is limited — always feature-detect and keep a default layout for unsupported browsers.
continuous means a flat screen posture (typical phones, tablets, desktops, or a foldable fully open/closed flat). folded means a book or laptop-style fold on a foldable device.
Call navigator.devicePosture.addEventListener("change", handler) and read navigator.devicePosture.type inside the handler.
Yes. The CSS media feature device-posture (for example @media (device-posture: folded)) can style layouts without JavaScript when supported.
No. The property is read-only. You read DevicePosture.type and listen for change events.
Did you know?
MDN pairs the JS API with a CSS media feature: @media (device-posture: folded) { … } — useful when you only need style changes.