The status bar overlaps the app content in Android 15. I can’t seem to change the design of the status bar, no matter what steps I follow. Not even the color of the status bar changes. Please help. I’m new to capacitor and I’ve tried everything. I’m using Capacitor in combination with Next.js 15, i’ve also installed the status bar plugin of capacitor.
This is my Header.tsx component, which is available everywhere throughout the website. I didn’t want to put this code in layout.tsx because I didn’t want my entire layout to be a client component:
useEffect(() => {
const configureStatusBar = async () => {
if (Capacitor.isNativePlatform()) {
// Prevent the status bar from overlaying the WebView
await StatusBar.setOverlaysWebView({ overlay: false });
// Set the status bar background color
await StatusBar.setBackgroundColor({ color: "#ffffff" }); // Replace with your desired color
// Set the status bar text and icon color
await StatusBar.setStyle({ style: Style.Dark }); // Use Style.Light for dark backgrounds
}
};
configureStatusBar();
}, []);
I’ve even set up the plugin in capacitor.config.ts:
Use StatusBar plugin correctly (for Cordova/Capacitor):
Make sure to install and configure it properly
npm install @awesome-cordova-plugins/status-bar
ionic cap sync
In app.component.ts
import { StatusBar } from '@awesome-cordova-plugins/status-bar/ngx';
constructor(private statusBar: StatusBar) {
this.platform.ready().then(() => {
this.statusBar.overlaysWebView(false); // This prevent content from going under status bar
this.statusBar.styleDefault();
});
}
The overlaysWebView api has bug on Android 15 (Edge to Edge display), Capacitor official documentation has already explained as below:
Whether the statusbar is overlaid or not. For applications targeting Android 15, this property has no effect unless the property windowOptOutEdgeToEdgeEnforcement is added to the application layout file. Otherwise, the application assumes always overlays as true. More details in R.attr | API reference | Android Developers