Capacitor 6 and 7 plugin to support edge-to-edge display on Android using WindowCompat.enableEdgeToEdge().
- âś… Edge-to-edge display support on Android
- âś… Safe area insets handling
- âś… Automatic layout adjustment for system bars
- âś… Keyboard aware - adjusts layout when keyboard is visible
- âś… Status bar & navigation bar color configuration
- âś… Visual protection - light/dark icon appearance
- âś… Immersive mode - fullscreen support for games and videos
- âś… Navigation bar contrast control
- âś… Keyboard animations support
npm install @squareetlabs/capacitor-android-edge-to-edge
npx cap syncThis plugin enables edge-to-edge display on Android using WindowCompat.enableEdgeToEdge() as recommended by the Android documentation.
Configuration in capacitor.config.ts:
import { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = {
plugins: {
EdgeToEdge: {
// Disable edge-to-edge when gesture navigation is detected
disableEdgeToEdgeForGesture: true
}
}
};
export default config;Important: If you are using the Capacitor Keyboard plugin, make sure to set the resizeOnFullScreen property to false (default) in your Capacitor Configuration file:
{
"plugins": {
"Keyboard": {
"resizeOnFullScreen": false
}
}
}Otherwise, the web view will be resized to fit the screen, which may cause issues with this plugin.
This plugin is compatible with:
- Capacitor 6.x
- Capacitor 7.x
- Minimum SDK: API level 22
- Uses
WindowCompat.enableEdgeToEdge()for Android R+ (API 30+) - Falls back to system UI flags for older Android versions
The plugin automatically applies edge-to-edge mode when the plugin loads. It applies insets to the web view to support edge-to-edge display on Android.
import { EdgeToEdge } from '@squareetlabs/capacitor-android-edge-to-edge';
// Enable edge-to-edge mode (called automatically on load)
const enable = async () => {
await EdgeToEdge.enable();
};
// Disable edge-to-edge mode
const disable = async () => {
await EdgeToEdge.disable();
};
// Get current insets (safe area)
const getInsets = async () => {
const result = await EdgeToEdge.getInsets();
console.log('Insets:', result);
// { top: 24, bottom: 48, left: 0, right: 0 }
};
// Configure status bar appearance (light icons)
await EdgeToEdge.setStatusBarAppearance({ light: true });
// Set status bar color (semi-transparent black)
await EdgeToEdge.setStatusBarColor({ color: '#80000000' });
// Set navigation bar color (transparent)
await EdgeToEdge.setNavigationBarColor({ color: '#00000000' });
// Configure navigation bar contrast (translucent vs transparent)
await EdgeToEdge.setNavigationBarContrastEnforced({ enforce: false });
// Enter immersive mode (fullscreen)
await EdgeToEdge.enterImmersiveMode();
// Exit immersive mode
await EdgeToEdge.exitImmersiveMode();
// Enable keyboard animations
await EdgeToEdge.setKeyboardAnimation({ enabled: true });
// Configure all settings at once
await EdgeToEdge.configure({
lightStatusBar: true,
lightNavigationBar: true,
statusBarColor: '#80000000',
navigationBarColor: '#00000000',
enforceContrast: false,
immersive: false
});
// For gesture navigation (recommended)
await EdgeToEdge.configureForGestureNavigation({
lightStatusBar: true,
lightNavigationBar: true,
statusBarColor: '#F54927',
immersive: false
});
// Check if device is using gesture navigation
const result = await EdgeToEdge.checkGestureNavigation();
console.log('Is gesture navigation:', result.isGestureNavigation);
// Disable edge-to-edge for gesture navigation
await EdgeToEdge.setConfiguration({
disableEdgeToEdgeForGesture: true
});Enable the edge-to-edge mode.
Returns: Promise<void>
Only available on Android.
Disable the edge-to-edge mode.
Returns: Promise<void>
Only available on Android.
Return the insets that are currently applied to the webview.
Returns: Promise<GetInsetsResult>
Only available on Android.
Set the status bar appearance (light or dark icons).
| Param | Type |
|---|---|
options |
SetStatusBarAppearanceOptions |
Returns: Promise<void>
Only available on Android.
Set the navigation bar appearance (light or dark icons).
| Param | Type |
|---|---|
options |
SetNavigationBarAppearanceOptions |
Returns: Promise<void>
Only available on Android.
Set the status bar color.
| Param | Type |
|---|---|
options |
SetStatusBarColorOptions |
Returns: Promise<void>
Only available on Android.
Set the navigation bar color.
| Param | Type |
|---|---|
options |
SetNavigationBarColorOptions |
Returns: Promise<void>
Only available on Android.
Control whether the navigation bar should have contrast enforced.
| Param | Type |
|---|---|
options |
SetNavigationBarContrastEnforcedOptions |
Returns: Promise<void>
Only available on Android.
Enter immersive fullscreen mode (hide system bars). Recommended for games, videos, and other immersive experiences.
Returns: Promise<void>
Only available on Android.
Exit immersive fullscreen mode (show system bars).
Returns: Promise<void>
Only available on Android.
Enter or exit immersive mode.
| Param | Type |
|---|---|
options |
SetImmersiveModeOptions |
Returns: Promise<void>
Only available on Android.
Check if currently in immersive mode.
Returns: Promise<IsImmersiveModeResult>
Only available on Android.
Enable or disable keyboard animation. This provides smooth animations when the keyboard appears/disappears.
| Param | Type |
|---|---|
options |
SetKeyboardAnimationOptions |
Returns: Promise<void>
Only available on Android.
Apply comprehensive edge-to-edge configuration with all settings.
| Param | Type |
|---|---|
options |
ConfigureOptions |
Returns: Promise<void>
Only available on Android.
Check if the device is using gesture navigation.
Returns: Promise<CheckGestureNavigationResult>
Only available on Android.
Set plugin configuration options.
| Param | Type |
|---|---|
options |
SetConfigurationOptions |
Returns: Promise<void>
Only available on Android.
| Prop | Type | Description |
|---|---|---|
bottom |
number |
The bottom inset that was applied to the webview. Only available on Android. |
left |
number |
The left inset that was applied to the webview. Only available on Android. |
right |
number |
The right inset that was applied to the webview. Only available on Android. |
top |
number |
The top inset that was applied to the webview. Only available on Android. |
| Prop | Type | Description |
|---|---|---|
light |
boolean |
true for light icons (dark background), false for dark icons (light background) |
| Prop | Type | Description |
|---|---|---|
light |
boolean |
true for light icons (dark background), false for dark icons (light background) |
| Prop | Type | Description |
|---|---|---|
color |
string |
Color in ARGB format (e.g., "#FF000000" for opaque black, "#80000000" for semi-transparent black) |
| Prop | Type | Description |
|---|---|---|
color |
string |
Color in ARGB format (e.g., "#FF000000" for opaque black, "#80000000" for semi-transparent black) |
| Prop | Type | Description |
|---|---|---|
enforce |
boolean |
true to enforce contrast (translucent), false for transparent |
| Prop | Type | Description |
|---|---|---|
enter |
boolean |
true to enter immersive mode, false to exit |
| Prop | Type | Description |
|---|---|---|
immersive |
boolean |
Whether the app is currently in immersive mode |
| Prop | Type | Description |
|---|---|---|
enabled |
boolean |
true to enable keyboard animation, false to disable |
| Prop | Type | Description |
|---|---|---|
lightStatusBar |
boolean |
true for light status bar icons (dark background), false for dark icons (light background). Default: false |
lightNavigationBar |
boolean |
true for light navigation bar icons (dark background), false for dark icons (light background). Default: false |
statusBarColor |
string |
Status bar color in ARGB format (e.g., "#FF000000" for opaque black) |
navigationBarColor |
string |
Navigation bar color in ARGB format (e.g., "#FF000000" for opaque black) |
enforceContrast |
boolean |
true to enforce navigation bar contrast (translucent), false for transparent. Default: true |
immersive |
boolean |
true to enter immersive mode (hide system bars). Default: false |
| Prop | Type | Description |
|---|---|---|
isGestureNavigation |
boolean |
Whether the device is using gesture navigation |
| Prop | Type | Description |
|---|---|---|
disableEdgeToEdgeForGesture |
boolean |
Disable edge-to-edge when gesture navigation is enabled |
MIT