Capacitor Foldable: fold state, hinge angle and Android and iPhone Duo support for Capacitor apps

Hi everyone :waving_hand:

I built a free, MIT-licensed Capacitor plugin for foldable phones: capacitor-foldable.

It works on Galaxy Z Fold and Flip, Pixel Fold, and iPhone Duo (iOS 27.1), and supports Capacitor 7 and 8.

What it does

  • Fold state and posture (flat, tabletop, book), with the hinge position and angle
  • Size classes, to tell the outer display from the inner one
  • A polyfill for the Device Posture and Viewport Segments web APIs, which Android WebView and Safari turn off, so plain CSS can react to the fold
  • Android rear display and dual screen modes

Ionic tabs on iPhone Duo
On iPhone Duo, native tab bars move to the side as a floating pill, but ion-tabs stays at the bottom. One import fixes that:

import '@erkamyaman/capacitor-foldable/ionic-tabs.css';

Without the plugin → with ionic-tabs.css:

While testing I also found that Ionic’s tab bar can disappear on iPhone Duo: the device sends a keyboard event on every fold. The plugin has an opt-in fix, installFoldablePolyfill({ ionicKeyboard: true }). The details are in the iPhone Duo guide.

It’s tested on Galaxy Z Fold8, Z Flip8 and Z Fold8 Ultra, Pixel Fold emulators, and the iPhone Duo simulator in every pose.

npm install @erkamyaman/capacitor-foldable

If it’s useful to you, a :star: on GitHub would mean a lot and helps other developers find it. I’d love to hear your feedback, ideas, or anything that doesn’t work on your device.