Skip to content

About

πŸ“± Capacitor plugin for foldable phones: πŸ“– fold state, posture, hinge angle, size classes, rear display and dual screen on Android, plus a polyfill for the Device Posture and Viewport Segments web APIs. https://erkamyaman.github.io/capacitor-foldable/

Topics

Resources

Contributing

Stars

48 stars

Watchers

1 watching

Forks

Latest commit

Β 

History

92 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Capacitor Foldable logo

Capacitor Foldable

@erkamyaman/capacitor-foldable

Fold state, posture, hinge angle, size classes and bar placement for foldable phones such as Galaxy Z Fold and Flip, Pixel Fold and iPhone Duo, in Capacitor apps.

πŸ“š Documentation API iPhone Duo guide Hinge Guess demo
Ionic tabs on iPhone Duo without the plugin With the plugin
Ionic tab bar across the fold in book posture Ionic tab bar moved to the side in book posture

Install

npm install @erkamyaman/capacitor-foldable
npx cap sync
Capacitor Plugin Install iOS
v9 beta v9.x beta npm install @erkamyaman/capacitor-foldable@next Size classes and iPhone Duo, iOS 16+. Setup in the release notes
v8.x v8.x npm install @erkamyaman/capacitor-foldable Size classes, plus iPhone Duo on Capacitor 8.5+ and iOS 27.1, built with any Xcode
v7.x v7.x npm install @erkamyaman/capacitor-foldable@latest-7 Size classes only

Android works on API 24+ with any foldable Jetpack WindowManager supports. The web build is a stub that reports flat.

Usage

import { Foldable } from '@erkamyaman/capacitor-foldable';

const { posture } = await Foldable.getFoldState(); // 'flat' | 'tabletop' | 'book'

Foldable.addListener('foldStateChange', ({ posture }) => {
  document.documentElement.dataset.posture = posture;
});

Prefer CSS? installFoldablePolyfill() fills in the Device Posture and Viewport Segments APIs that Capacitor's web views turn off, and sets --fold-* variables and classes on <html>. Using ion-tabs? import '@erkamyaman/capacitor-foldable/ionic-tabs.css'.

Everything else is in the documentation.

Guides

Agent skill

npx skills add erkamyaman/capacitor-foldable@capacitor-foldable

Also ships in the npm package under skills/, and on its own at iphone-duo-capacitor-skills.

Used by

  • Capacitor Native UI and Ionic Theme iOS 27 by rdlabo
  • RecipeSage, a collaborative recipe keeper and meal planner, moves its native tab bar to the side on iPhone Duo with it
  • AI Gist, a privacy-first AI prompt manager, moves its tab bar to the side rail on iPhone Duo with it, alongside rdlabo's theme
  • Hinge Guess, a game where the phone's hinge is the controller

Trademarks and licence

This plugin is MIT licensed, and that covers the work in this repository. Quoted passages from Apple's and Google's documentation belong to them and are used here to explain their guidance.

iPhone and iPhone Duo are trademarks of Apple Inc., registered in the U.S. and other countries. Android and Pixel are trademarks of Google LLC. Galaxy Z Fold and Galaxy Z Flip are trademarks of Samsung Electronics Co., Ltd. This project is not affiliated with, endorsed by, or sponsored by any of them; the names appear only to say which devices the plugin works with.

About

πŸ“± Capacitor plugin for foldable phones: πŸ“– fold state, posture, hinge angle, size classes, rear display and dual screen on Android, plus a polyfill for the Device Posture and Viewport Segments web APIs. https://erkamyaman.github.io/capacitor-foldable/

Topics

Resources

Contributing

Stars

48 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages