safe-area-handling
БесплатноБез исполняемых скриптовНе проверенFixes notch, Dynamic Island, home indicator, display cutout, and system bar overlap in Capacitor apps. Covers `viewport-fit=cover` + `env(safe-area-inset-*)`…
от Cap-go★ 79 звёзд на GitHubОб этом скилле
Safe Area Handling in Capacitor
When to Use
TRIGGER when:
- Content renders under the status bar, notch, Dynamic Island, cutout, home indicator, or Android navigation/gesture bar
env(safe-area-inset-*)is0pxon Android, or correct only after rotation- Layout broke after Capacitor 8 upgrade or raising
targetSdkVersionto 35/36 StatusBar.setOverlaysWebView/setBackgroundColorstopped working on Android- Landscape / split-screen / iPad windowed layouts have wrong side padding
Do not use:
- Keyboard covering inputs:
capacitor-keyboard - Ionic
ion-header/ion-toolbartheming:ionic-design; KonstasafeAreas:konsta-ui - Tailwind plugin/utility setup:
tailwind-capacitor - iOS scene sizing,
UIScreen.main, multi-window:capacitor-ios-resizability - Splash screen colors:
capacitor-splash-screen
Facts that drive every decision
| Platform / version | Behavior |
|---|---|
| iOS (all) | WebView is full-screen. env(safe-area-inset-*) works only with viewport-fit=cover. ios.contentInset defaults to never. |
| Android, Capacitor <= 7 | android.adjustMarginsForEdgeToEdge config could add native margins. |
| Android, Capacitor 8+ | adjustMarginsForEdgeToEdge removed. SystemBars core plugin (in @capacitor/core) handles insets. |
| Android 15 (targetSdk 35) | Edge-to-edge enforced; opt-out via windowOptOutEdgeToEdgeEnforcement still possible. |
| Android 16 (targetSdk 36, Capacitor 8 default; 37 on Capacitor 9) | Opt-out ignored. @capacitor/status-bar overlaysWebView and backgroundColor have no effect. |
| Android WebView < 140 | env(safe-area-inset-*) wrong/0 (Chromium bug). SystemBars injects --safe-area-inset-* variables (default insetsHandling: 'css'). |
How SystemBars behaves on Android (from core source): if the page has viewport-fit=cover and WebView >= 140, insets pass through to env() and the WebView is edge-to-edge. Otherwise Capacitor pads the WebView natively so content sits between the bars and env() reports 0. --safe-area-inset-* variables carry correct values in both cases when insetsHandling is css.
Workflow
- Inspect:
index.htmlviewport meta,capacitor.config.*(ios.contentInset,android.adjustMarginsForEdgeToEdge,plugins.SystemBars,plugins.StatusBar),@capacitor/core+@capacitor/status-barversions,android/variables.gradletargetSdkVersion, global CSS that setspadding-top, UI framework (Ionic / Konsta handle insets themselves). - Decide the design: full-bleed (draw under bars, pad content) vs. contained (content between bars). Ask the user if mockups are unclear.
- Full-bleed (recommended):
viewport-fit=cover+ the CSS fallback chain below, applied once at the layout shell, not per component. - Remove legacy config: delete
android.adjustMarginsForEdgeToEdge; drop Android uses ofStatusBar.setOverlaysWebView/setBackgroundColor(keep for iOS if wanted); preferSystemBars.setStylefor icon color. - Framework check: Ionic already applies
--ion-safe-area-*; Konsta usessafeAreas. Do not double-pad. - Verify on devices (below).
Only load a reference when its topic is in play:
- references/android-edge-to-edge.md - SystemBars config, status-bar migration, nav bar color, WebView version checks
- references/css-patterns.md - layout shell, tab bars, reading insets in JS, debug overlay, resizable windows
Baseline
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
:root {
--sat: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
--sar: var(--safe-area-inset-right, env(safe-area-inset-right, 0px));
--sab: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
--sal: var(--safe-area-inset-left, env(safe-area-inset-left, 0px));
}
.app-header { padding-top: var(--sat); padding-inline: var(--sal) var(--sar); }
.app-tabbar { padding-bottom: var(--sab); padding-inline: var(--sal) var(--sar); }
The --safe-area-inset-* names are injected by Capacitor's SystemBars on Android; on iOS and web they are undefined, so the env() fallback applies.
import { SystemBars, SystemBarsStyle } from '@capacitor/core';
await SystemBars.setStyle({ style: SystemBarsStyle.Dark }); // light icons on dark background
SystemBarsStyle.Dark = light content for dark backgrounds; Light = dark content. iOS needs UIViewControllerBasedStatusBarAppearance = YES (template default).
Traps
- Missing
viewport-fit=coveris the #1 cause ofenv()= 0 on iOS and of Capacitor padding the WebView on Android. - Do not combine
ios.contentInset: 'always'with CSS safe-area padding: insets apply twice. - Do not hardcode 20/44/47/59 px status bar heights; heights differ per device, orientation, and window size.
- Insets change at runtime (rotation, iPad windowed mode, foldables, Android sp
Установить safe-area-handling в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл safe-area-handling?
Fixes notch, Dynamic Island, home indicator, display cutout, and system bar overlap in Capacitor apps. Covers `viewport-fit=cover` + `env(safe-area-inset-*)`, the Capacitor 8 SystemBars core plugin (`insetsHandling`, injected `--safe-area-inset-*` CSS variables for Android WebView < 140, removal of `android.adjustMarginsForEdgeToEdge`), Android 15/16 enforced edge-to-edge (`overlaysWebView` and `backgroundColor` of @capacitor/status-bar no longer work at targetSdk 36), iOS `contentInset`, and insets that change at runtime on rotation, iPad/foldable resizable windows. Use when headers sit under the status bar, tab bars hide behind the gesture bar, `env()` returns 0 on Android, or layout broke after upgrading to Capacitor 8 / targetSdk 35+. Do not use for keyboard overlap (capacitor-keyboard), Ionic/Konsta component theming (ionic-design, konsta-ui), Tailwind utility setup (tailwind-capacitor), or iOS multi-window/resizability adoption (capacitor-ios-resizability).
Как установить скилл safe-area-handling?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл safe-area-handling запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
от Anthropicwebapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
от Anthropicbrand-guidelines
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
от Anthropicweb-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…
от Anthropic