import { HomeIndicator } from '@capgo/home-indicator';
// Hide the home indicatorawait HomeIndicator.hide();
Install the package
npm i @capgo/home-indicator
pnpm add @capgo/home-indicator
yarn add @capgo/home-indicator
bun add @capgo/home-indicator
Sync with native projects
npx cap sync
pnpm cap sync
yarn cap sync
bunx cap sync
Configure the plugin
import { HomeIndicator } from '@capgo/home-indicator';
// Hide the home indicatorawait HomeIndicator.hide();
// Show the home indicatorawait HomeIndicator.show();
// Check visibility statusconst { hidden } = await HomeIndicator.isHidden();console.log('Is hidden:', hidden);
No additional setup required. The plugin only works on iOS devices with a home indicator (iPhone X and later).
This plugin has no effect on Android devices as they donβt have an iOS-style home indicator.
Auto-hide configuration
import { HomeIndicator } from '@capgo/home-indicator';
// Configure auto-hide behaviorawait HomeIndicator.setAutoHidden({ autoHidden: true // Enable auto-hide});
// The home indicator will automatically hide after a few seconds// and reappear when the user touches the screen
Advanced usage
import { HomeIndicator } from '@capgo/home-indicator';import { App } from '@capacitor/app';
export class ImmersiveMode { private isImmersive = false;
async enterImmersiveMode() { this.isImmersive = true;
// Hide home indicator await HomeIndicator.hide();
// Enable auto-hide for better UX await HomeIndicator.setAutoHidden({ autoHidden: true });
// Hide status bar for full immersion // StatusBar.hide(); // If using @capacitor/status-bar }
async exitImmersiveMode() { this.isImmersive = false;
// Show home indicator await HomeIndicator.show();
// Disable auto-hide await HomeIndicator.setAutoHidden({ autoHidden: false });
// Show status bar // StatusBar.show(); // If using @capacitor/status-bar }
async toggleImmersiveMode() { const { hidden } = await HomeIndicator.isHidden();
if (hidden) { await this.exitImmersiveMode(); } else { await this.enterImmersiveMode(); } }
setupAppLifecycle() { // Handle app state changes App.addListener('appStateChange', async ({ isActive }) => { if (!isActive && this.isImmersive) { // App went to background, might want to show indicator await HomeIndicator.show(); } else if (isActive && this.isImmersive) { // App came to foreground, restore immersive mode await HomeIndicator.hide(); } }); }}
hide()
Hide the home indicator.
Returns: Promise<void>
show()
Show the home indicator.
Returns: Promise<void>
isHidden()
Check if the home indicator is currently hidden.
Returns: Promise<{ hidden: boolean }>
setAutoHidden(options: { autoHidden: boolean })
Configure auto-hide behavior for the home indicator.
Parameters:
options.autoHidden
: boolean - Enable or disable auto-hideReturns: Promise<void>
interface AutoHiddenOptions { autoHidden: boolean;}
interface HiddenResult { hidden: boolean;}
User Control: Always provide a way to exit immersive mode
// Add a gesture or button to toggle immersive modeconst toggleButton = document.getElementById('toggle-immersive');toggleButton.addEventListener('click', () => { immersiveMode.toggleImmersiveMode();});
Auto-Hide for Games: Use auto-hide for better gaming experience
// For games, auto-hide provides the best balanceawait HomeIndicator.setAutoHidden({ autoHidden: true });
Respect System Gestures: Donβt interfere with system navigation
Save State: Remember userβs preference for immersive mode
Home indicator not hiding:
Auto-hide not working:
Indicator reappears unexpectedly: