JavaScript Navigator devicePosture Property

Beginner
⏱️ 10 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Experimental

What You’ll Learn

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

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.

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: "continuous" — flat posture (typical devices; foldables fully flat).
  • type: "folded" — book / laptop fold posture on foldables.
  • change — event when posture updates.
  • CSS@media (device-posture: continuous | folded) when supported.

📝 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);
}

⚡ Quick Reference

GoalCode
Get DevicePosturenavigator.devicePosture
Detect API"devicePosture" in navigator
Current posturenavigator.devicePosture.type
Listen for updatesdevicePosture.addEventListener("change", fn)
Flat?type === "continuous"
Folded?type === "folded"

🔍 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

📋 JS devicePosture vs CSS Media

navigator.devicePosture@media (device-posture: …)
LanguageJavaScriptCSS
Best forLogic, analytics, dynamic componentsLayout / spacing / visibility
Live updateschange eventMedia query re-evaluation
SupportExperimental / limitedSame API family — still limited
Use together?Yes — CSS for styles, JS for behavior when both exist

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.

📚 Getting Started

Detect the API and read the current posture type.

Example 1 — Feature Detection

Check whether devicePosture exists on navigator.

JavaScript
const supported = "devicePosture" in navigator;
console.log(supported ? "devicePosture available" : "devicePosture missing");
Try It Yourself

How It Works

Many browsers omit this API today. Keep a standard responsive layout as the default.

Example 2 — Read type

Print continuous or folded when supported.

JavaScript
if (!("devicePosture" in navigator)) {
  console.log("unsupported");
} else {
  console.log("type: " + navigator.devicePosture.type);
}
Try It Yourself

How It Works

Non-foldables that expose the API typically stay on continuous.

📈 Practical Patterns

MDN reporting, UI adaptation, and change listeners.

Example 3 — MDN Report Helper

Update a status string from type (MDN sample shape).

JavaScript
function reportPostureOutput() {
  if (!("devicePosture" in navigator)) {
    return "Device posture: unsupported";
  }
  // type returns "continuous" or "folded"
  return "Device posture: " + navigator.devicePosture.type;
}

console.log(reportPostureOutput());
Try It Yourself

How It Works

Reuse this function for the initial paint and for every change event.

Example 4 — Adapt Layout Mode

Pick a UI mode from posture with a safe default.

JavaScript
function pickLayoutMode() {
  if (!("devicePosture" in navigator)) return "standard";
  return navigator.devicePosture.type === "folded"
    ? "split-panels"
    : "standard";
}

console.log("layout: " + pickLayoutMode());
Try It Yourself

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
Try It Yourself

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.

🚀 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.

📝 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.
  • Consider CSS @media (device-posture: …) alongside JS.
  • Related: doNotTrack, Window, JavaScript hub.

Limited Browser Support

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.

Limited Not Baseline
Google Chrome Experimental / limited — check flags & foldable support
Limited
Microsoft Edge Chromium-based — follow Chrome Device Posture status
Limited
Opera Chromium-based — check current compat
Limited
Mozilla Firefox Not available for typical web content
Unavailable
Apple Safari Not available for typical web content
Unavailable
devicePosture Limited

Bottom line: Detect devicePosture, adapt when present, and keep a solid responsive default for everyone else.

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.

Continue with doNotTrack, Window methods, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Feature-detect before reading type
  • Default to a solid responsive layout
  • Listen for change on foldables
  • Pair with CSS device-posture when available
  • Test on real foldables when possible

❌ Don’t

  • Require Device Posture for core navigation
  • Assume every phone can report folded
  • Ignore unsupported browsers
  • Build layouts that only work when folded
  • Ship without checking MDN compatibility

Key Takeaways

Knowledge Unlocked

Five things to remember about devicePosture

Foldable posture sensor — continuous or folded.

5
Core concepts
📄 02

Flat

continuous

Type
📚 03

Folded

folded

Type
🔄 04

Updates

change event

Live
🔬 05

Status

Experimental

Detect

❓ Frequently Asked Questions

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.

Learn doNotTrack Next

Deprecated Do Not Track signal — and what to use instead.

doNotTrack →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful