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()
- There are four values:
safe-area-inset-top,safe-area-inset-right,safe-area-inset-bottomandsafe-area-inset-left. - They work inside
calc(), as in.tab-barabove. - Where no inset is known, the value is 0. The padding collapses instead of breaking the layout.
Where the insets come from
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:
- 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 withpb-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.
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:
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:
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: truesafeAreaTop,safeAreaRight,safeAreaBottomandsafeAreaLeft: 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.
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.
isNotchScreen()is a signal that'struewhen 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 thatng build --platformmakes pass it.platformis 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_BOTTOMandSAFE_AREA_INSET_LEFTare theenv()strings, such as'env(safe-area-inset-top)', for building styles in TypeScript.
