/ionic-capacitor-skills:capacitor-foldablefrom ionic-capacitor-skills
Builds Capacitor apps that adapt to foldable devices (iPhone Duo, Android foldables) using CSS custom properties and polyfills for Device Posture and Viewport Segments APIs.
Ships in ionic-capacitor-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Guidance for @erkamyaman/capacitor-foldable, which reports the fold to a Capacitor web view: where the crease is, the hinge angle, the posture, and which display the app is on.
This skill is new. Everything in it was checked against the plugin source and measured on the iPhone Duo simulator, but it has not been through much real use yet, so report anything that misleads you.
npm install @erkamyaman/capacitor-foldable
npx cap sync
Capacitor 8 uses the current major. If you are on Capacitor 7 and building with Xcode 27, upgrade to 8.5 or later before anything else: those apps crash at launch, because iOS 27 needs the scene lifecycle that only 8.5 adopted, and a crash on launch is an automatic App Review rejection. Capacitor 7 apps can install @erkamyaman/capacitor-foldable@7 and build with Xcode 26, which reports the fold on Android and size classes everywhere but has no iPhone Duo support. That route closes when Apple requires the iOS 27 SDK in April 2027. The 7.x line also predates the --fold-* variables (8.1.0) and the Ionic tab stylesheets, so the CSS below needs Capacitor 8.
Install the polyfill once at startup, then lay out with CSS. Most foldable work needs no JavaScript at all.
import { Foldable, installFoldablePolyfill } from '@erkamyaman/capacitor-foldable';
await installFoldablePolyfill();
Whenever the device reports a fold, that sets --fold-left, --fold-top, --fold-width, --fold-height and --fold-margin-* on <html>, and adds fold-vertical or fold-horizontal. It also sets the vertical-bars-* classes the Ionic stylesheet needs, and fills in the standard Viewport Segments and Device Posture APIs. Android's WebView turns both off, and Safari 27.1 has them behind an off-by-default flag that only Safari can set, so a Capacitor web view gets neither. The polyfill stands aside if it ever finds them already there.
Prefer the --fold-* variables over the polyfilled segment variables for layout: the segments only split when the fold actually separates the window, which on iPhone Duo means half open, while the fold variables are there when it is open flat too.
.fold-vertical .reader { position: fixed; inset: 0; }
.fold-vertical .reader .page {
position: absolute;
top: 0;
bottom: 0;
padding: 14px;
box-sizing: border-box;
}
.fold-vertical .reader .page:first-child { left: 0; width: var(--fold-left); }
.fold-vertical .reader .page:last-child { left: calc(var(--fold-left) + var(--fold-width)); right: 0; }
On a phone with no fold there are no --fold-* variables and no fold-* class, so write the flat layout first and let these rules refine it. The install is also a no-op off native, so nothing appears in a desktop browser: iterate in the simulator or on a device.
Handle both orientations. On iPhone Duo the crease is vertical in landscape and horizontal in portrait, so a layout that only styles .fold-vertical flattens when the phone is turned.
Reach for the plugin's methods when CSS cannot answer the question: the hinge angle, the posture, which display you are on, or where the system put its bars.
ion-tabs on the side, the keyboard event a fold fires, Angular's CSS rule): ionic.mdvar(--fold-left), never on 50%. The variables give the band's leading edge, not its centre, and the coordinates are measured against the web view, so any inset moves them off the viewport midpoint. On iPhone Duo the fold is a 40 point band, so a halfway split also lands inside the part the system wants kept clear.--fold-width as the keep-clear band. The margins are inside it, so --fold-margin-* tells you how much of the band is margin rather than physical crease. Do not add them on top of it. They are iOS only and read 0px on Android, where a seamless fold also reports zero width, so keep your own minimum clearance: max(12px, var(--fold-width, 0px)), with the fallback because the variable does not exist at all on a phone with no fold.state: 'flat' and no hingeBounds, because the plugin drops the fold below 20 degrees.setVerticalBarBehavior({ behavior: 'disabled' }) to avoid adapting. Apple's HIG asks you not to override bar placement. UIKit's own reference gives the exception: disable it only for interfaces better served by horizontal bars, "such as a fullscreen video player with toolbar controls or a non-scrolling layout like a calculator". It returns the bars to horizontal; it does not hand you the full display.getFoldState() on a timer when foldStateChange will tell you. The exception is the moment the app moves between displays, where iOS pauses the web view: see iphone-duo.md.isDeviceFoldable() answers the first, though it can answer false on an Android foldable that advertises no tabletop posture and no hinge sensor. The presence of hingeBounds, or --fold-left in CSS, answers the second, and is what layout should key on. For the outer screen, neither is the gate: use getDisplayModes() and displayModeChange, since rear display and dual screen are Android only and read unsupported on iPhone Duo even though it folds. Every read method answers safely on any device; startRearDisplay() and startDualScreen() reject when the mode is unavailable.npm run build # or the app's build
npx cap sync
Then run it open flat, half open and closed, and fold it shut and open again, which suspends and resumes the web view on iOS. Do one pass at the largest system text size and one with VoiceOver or TalkBack on, since a layout that splits at the crease is exactly where reading order and target sizes go wrong. On iPhone Duo the posture picks the display, so that covers both screens; on Android the outer display needs rear display mode. testing.md has the commands.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
18 skills in this plugin
/ionic-analyticsAdd product analytics to an Ionic Capacitor app — Firebase Analytics or PostHog. Trigger when adding event tracking, screen views, funnel analytics, A/B testing, or user behavior tracking to an Ionic mobile app./ionic-angularBuild a production-ready Ionic Capacitor mobile app with Angular standalone components, lazy-loaded routes, services for cross-cutting concerns, and @ngx-translate/core for i18n. Trigger when the user wants to create an Ionic Angular app, scaffold pages (onboarding, paywall, tabs, settings), or wire RevenueCat / AdMob / push notifications into an Angular Ionic project./ionic-app-icon-splashGenerate every iOS and Android app icon and splash screen size from a single source PNG using @capacitor/assets. Trigger when adding app icons, generating splash screens, replacing the default Capacitor icon, or shipping any Ionic Capacitor app to a store (icons are non-optional)./ionic-apple-sign-inAdd "Sign in with Apple" to an Ionic Capacitor app via @capacitor-community/apple-sign-in. Trigger when adding social login on iOS, integrating Apple ID as a sign-in method, or when App Review requires Sign in with Apple alongside other social logins./ionic-attRequest iOS App Tracking Transparency (ATT) permission so AdMob can serve personalized ads on iOS 14+ without App Review rejecting the build. Trigger when adding ATT, IDFA permission, or "iOS personalized ads" to an Ionic Capacitor app./ionic-biometric-authAdd Face ID / Touch ID / fingerprint authentication to an Ionic Capacitor app via @aparajita/capacitor-biometric-auth. Trigger when adding biometric login, app lock, secure reauthentication, or Face ID/Touch ID gating to a sensitive feature.npx claudepluginhub erkamyaman/ionic-capacitor-skills --plugin ionic-capacitor-skillsOther plugins' skills for the same job