-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Capacitor Version
https://capacitorjs.com/docs/apis/system-bars#android-note
The CSS is not being applied on Android mobiles with API <= 34.
In an SDK 36 build.
I have tested it on API versions 29, 34, 35 and 36. All tests were performed with the webview updated to the latest version.
If there is an API limitation preventing the safe-area-inset-x from being implemented, it is not mentioned in the documentation.
It is configured in the config file and in the global CSS.
const config: CapacitorConfig = {
...
plugins: {
SystemBars: {
insetsHandling: 'css'
}
}
};
html {
--ion-safe-area-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
--ion-safe-area-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
--ion-safe-area-left: var(--safe-area-inset-left, env(safe-area-inset-left, 0px));
--ion-safe-area-right: var(--safe-area-inset-right, env(safe-area-inset-right, 0px));
}
In an emulator with Android API 35 and 36, it injects correctly:
The problem lies in the difficulty of maintaining a consistent strategy with API 36 and the global setting insetsHandling: 'css'.
This is because the safe area is injected into some models but not others, so you can't apply edge-to-edge handling in any API without resorting to StatusBar.setOverlaysWebView({ overlay: true }); in older versions.
I've seen this pull request, which I'm not sure if it resolves these issues:
#8384
Other API Details
node --version
v24.14.0
npm --version
11.11.1Platforms Affected
- iOS
- Android
- Web
Current Behavior
CSS is not injected in versions lower than API 34
Expected Behavior
CSS is injected in earlier versions. If this isn't possible, please indicate it in the documentation at https://capacitorjs.com/docs/apis/system-bars
Project Reproduction
https://github.com/Marius-Romanus/demo-safe-area
Additional Information
The project I'm sharing is a simple fresh installation of Ionic and Capacitor, since the CSS is displayed directly in the HTML.