capacitor: bug: SafeArea for iphoneX in notch
Bug Report
Capacitor Version
npx cap doctor output:
π Capacitor Doctor π
Latest Dependencies:
@capacitor/cli: 1.3.0
@capacitor/core: 1.3.0
@capacitor/android: 1.3.0
@capacitor/ios: 1.3.0
Installed Dependencies:
@capacitor/cli 1.3.0
@capacitor/core 1.3.0
@capacitor/android 1.3.0
@capacitor/ios 1.3.0
Affected Platform(s)
- Android
- iOS
- Electron
- Web
Current Behavior
Currently in iphone X there is no safe area for the webview, in order to see the content correctly and not overlap the notification bar.
Expected Behavior
It is desired that there is a safearea for the webview on an iPhone X, so that the content is viewed correctly and does not overlap the notification bar.
Sample Code or Sample Application Repo
Reproduction Steps
Other Technical Details
npm --version output:
6.9.0
node --version output:
v10.16.3
pod --version output (iOS issues only):
1.8.4
Other Information

About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (1 by maintainers)
Yes, this is web/css concern, not a Capacitor one. For what itβs worth, Ionic Framework handles this for you.
Forget it, I was missing the viewport-fit=cover in the meta tag. Thanks!
You should use CSS for this: https://webkit.org/blog/7929/designing-websites-for-iphone-x/
If you need to know the safe area insets in JS, you can do this using this library: https://github.com/zhetengbiji/safeAreaInsets
I am doing this and it works perfectly.
webview inside capacitor is returning 0 for env(safe-area-inset-top) in an iPhone X
Unfortunately it does not work with android yet.
@mcqj capacitor does not provide you with those values as itβs not needed - the browser that your app runs inside already has this information and you can access it using css with or without js (see links I posted previously).
FWIW, I recently had to implement this as well. The approach I took that worked was: