For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /guide/safe-area.md.

Safe area

Keep content clear of the notch, the status bar and the home indicator. Lynx reads the same env(safe-area-inset-*) values that iOS Safari does.

The safe area is the part of the screen that hardware and system bars don't cover. On a recent iPhone:

  • The notch or Dynamic Island covers the top edge.
  • The home indicator (the bar you swipe up) covers the bottom.

On the web, a page with viewport-fit=cover pads itself with env(safe-area-inset-top) and its siblings. Lynx supports the same four values.

Pad with env()

.screen {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.tab-bar {
  /* a 56px bar, plus room for the home indicator */
  height: calc(56px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
}
  • There are four values: safe-area-inset-top, safe-area-inset-right, safe-area-inset-bottom and safe-area-inset-left.
  • They work inside calc(), as in .tab-bar above.
  • Where no inset is known, the value is 0. The padding collapses instead of breaking the layout.

Where the insets come from

Where the app runsWhat env() gives
Apps from ng build --platformThe window's insets, on iOS and Android, following rotation. 0 on every side with "edgeToEdge": false
Lynx Explorer on iPhoneThe window's insets, wherever your page sits on screen
Your own iOS appThe window's insets when the LynxView was created, or the insets your app sends (see below)
Your own Android app0 on every side, unless your app sends the insets (see below): Lynx doesn't read them on Android
Web preview0

The apps ng build --platform makes

They draw the page edge to edge: over the whole screen, under the status bar and the home indicator. Safari does the same for a page with viewport-fit=cover.

  • A scroll view's content scrolls under the status bar.
  • A header image or a map reaches the top edge.
  • A bar that floats at the bottom, such as the dock, floats over a page that runs to the bottom of the screen.

Pad the content, not the screen:

<scroll-view scroll-orientation="vertical" class="flex-1">
  <view class="flex flex-col px-4 pt-safe-3 pb-safe-24">
    <!-- the first row starts below the status bar, and scrolls under it -->
  </view>
</scroll-view>
  • Overlays cover the whole screen too. An <overlay>, and so a bottom sheet or a dialog, reaches the bottom edge. Pad its content too, as the bottom sheet does with pb-safe.
  • env() follows the insets when they change: when the phone rotates, and on Android when the keyboard opens.
  • The Android keyboard pushes the page up, so the input you type into stays above it. The bottom inset is 0 while it's open, because the page then ends above the navigation bar.

The apps send the insets as numbers too, with isNotchScreen and edgeToEdge: see What the generated apps pass.

Don't define a CSS variable with

In a stylesheet, --gap: calc(env(safe-area-inset-top) + 8px) keeps Lynx's own env(), which is 0 in these apps. Write env() where the variable is read instead:

padding-top: calc(env(safe-area-inset-top) + 8px);

Why: Lynx's own env() can't follow the window. On Android it's always 0, and on iOS each element reads it once.

So the build points each env(safe-area-inset-*) in a stylesheet at a CSS variable the page sets from the app's insets. The runtime writes the insets into inline styles and style bindings itself. A CSS variable defined in a stylesheet is the one place neither reaches.

Turn edge to edge off

To keep the page inside the safe area instead, set edgeToEdge to false in the build target's options in angular.json:

angular.json
"options": {
  "appName": "Example",
  "appId": "com.example.app",
  "edgeToEdge": false
}

The page then starts below the status bar and ends above the home indicator, and env() is 0 on every side.

Your own app

On iOS, Lynx reads the window's insets each time a LynxView is created, and never again:

  • A LynxView created before its window is shown reads 0.
  • One on screen keeps the insets it read, even when the phone rotates.

To have env() follow the window as the generated apps do, send the same global props they send. This works on Android too.

  • edgeToEdge: true
  • safeAreaTop, safeAreaRight, safeAreaBottom and safeAreaLeft: the part of the LynxView the system bars cover

Send them again whenever they change.

Tailwind utilities

The UI components' theme adds padding utilities built on env():

  • Tailwind 4: its tailwind.css.
  • Tailwind 3: its Tailwind plugin, blotchPlugin.

npx @blotch/dolan init copies the one your app needs into your project.

<!-- padding equal to the inset -->
<view class="pb-safe">...</view>

<!-- 1rem of padding plus the inset: calc(1rem + env(safe-area-inset-bottom)) -->
<view class="pb-safe-4">...</view>
ClassPadding
pt-safe pr-safe pb-safe pl-safeThe inset on one side
px-safe py-safeThe insets on two opposite sides
p-safeThe insets on all four sides
pt-safe-<n> pb-safe-<n> and so onA spacing value plus the inset

The <n> takes any value from your spacing scale, as p-<n> does: pb-safe-8, pt-safe-2.

Check for a notch in TypeScript

Prefer CSS: env() adapts to every device without code. For logic CSS can't express, inject LynxSafeArea.

src/app/header.ts
import { Component, inject } from '@angular/core';
import { LYNX_ELEMENTS, LynxSafeArea } from '@blotch/angular-lynx';

@Component({
  selector: 'app-header',
  imports: [LYNX_ELEMENTS],
  template: `
    <view
      class="app-header"
      [class.app-header-notch]="safeArea.isNotchScreen()"
    >
      <text>Inbox</text>
    </view>
  `,
  styles: `
    .app-header {
      padding: 12px 16px;
    }
    .app-header-notch {
      padding-top: calc(12px + env(safe-area-inset-top));
    }
  `,
})
export class Header {
  protected readonly safeArea = inject(LynxSafeArea);
}
  • isNotchScreen() is a signal that's true when the device has a notch or camera cutout. It comes from the host app (the native app that runs your bundle). Lynx Explorer and the apps that ng build --platform makes pass it.
  • platform is the operating system. On phones it's 'iOS', 'Android' or 'Harmony', which is Huawei's HarmonyOS.
  • SAFE_AREA_INSET_TOP, SAFE_AREA_INSET_RIGHT, SAFE_AREA_INSET_BOTTOM and SAFE_AREA_INSET_LEFT are the env() strings, such as 'env(safe-area-inset-top)', for building styles in TypeScript.