Buklanadigan telefonlar biz bilan qoladi: Web dasturchilar yangi Device API lar haqida nima bilishi kerak?

Buklanadigan telefonlar biz bilan qoladi: Web dasturchilar yangi Device API lar haqida nima bilishi kerak?

Okt 09, 2026 web development foldable phones device posture api viewport segments mobile development responsive design javascript css apple iphone duo web apis

Foldable Phones Are Here—Is Your Website Ready?

Okay, confession time. I've been watching foldable phones from a distance for years, quietly jealous of Android users who got to play with those futuristic devices while I was stuck with my boring flat screens. Then Apple finally jumped into the game, and honestly? That changes everything—not just for phone enthusiasts, but for anyone building websites.

I spent a weekend messing with the iPhone Duo simulator (don't judge me), and I was genuinely impressed. Apple released a whole series of videos about building for the Duo, and while most of that covers native iOS development, there's plenty of good stuff for web developers too. Let's look at what's actually usable right now.

Device Posture API: Is Your Screen Bent or Flat?

This is a simple but powerful tool. The Device Posture API tells your code what physical state the device is in—is it lying flat like a normal phone, or is it folded partially open like a tiny laptop?

Here's how you use it in JavaScript:

navigator.devicePosture

It returns either continuous (completely flat) or folded (partially closed). But you can also handle this directly in CSS:

@media (device-posture: folded) {
  .app-container {
    flex-direction: column;
  }
}

Picture this: you're watching a video on a folded Duo. Your player could automatically shift all the controls to the bottom screen while the video plays on top. That's the kind of smart adaptation this API enables.

Viewport Segments API: Understanding the Split

If the first API tells you how the device is positioned, this one tells you what it looks like. When a foldable phone folds in half, it creates separate screen areas. This API lets you ask: "Hey, what are the dimensions of each screen section?"

In JavaScript:

window.visualViewport.segments

This gives you an array of objects, each describing a screen segment's size and position. But CSS is where it gets really elegant:

@media (horizontal-viewport-segments: 2) {
  .content-grid {
    grid-template-columns: env(viewport-segment-width 0 0) env(viewport-segment-width 1 0);
  }
}

Those env() variables are clever. env(viewport-segment-width 1 0) grabs the width of the segment at horizontal position 1, vertical position 0. Takes a second to understand the coordinate system, but once it clicks, you can do some pretty cool layouts.

Why Should You Care?

Foldable phones aren't some weird niche product anymore. They're going mainstream, and the web is already catching up to support them.

For developers, this opens up entirely new design possibilities. A travel app could show a map on one screen and booking options on the other. An online store could put product photos on one side and customer reviews on the other. Developers could finally have a proper split-screen experience for mobile without needing to build a native app.

Think of the fold as a feature, not a compromise. With these APIs, you can create experiences that feel like they were made specifically for foldable hardware, while still working perfectly fine for everyone on regular devices.

Ready to Experiment?

Here's the best part—you don't need to buy a $1,500 foldable phone to start playing with this. Safari Technology Preview and Chrome DevTools both have built-in simulators. Load up a virtual device, switch between flat and folded modes, and watch your layouts adapt in real-time.

If you run a business website or web application, now is a good time to review your responsive design approach. The question isn't whether foldable phones will become important—it's whether your site will be ready when your visitors start showing up with them.

The web platform keeps surprising us with how quickly it evolves when new hardware pushes the boundaries. Time to start thinking about how your projects can fold alongside it.

Read in other languages:

ES TR SV BG RU CS EL FI DA DE ZH-HANS RO PL HU PT EN