Skip to content

SafeArea ​

When a mobile app embeds a web view or a full-screen H5 page, the notch and the home-indicator area can cover content. oas-safe-area reads env(safe-area-inset-top) / env(safe-area-inset-bottom) and reserves that height as a layout spacer at the top or bottom of the page.

  • Pure CSS spacer: no keyboard focus, no interaction, no events
  • The default slot can hold decorative dots; accessibility is up to the host
  • On desktop env(...) is 0 — use size to set an explicit height for demos or fallbacks

Basic Usage ​

Bottom safe area (size=24 simulates the gesture area)

Page content

Top / Bottom ​

position="top" reads the top notch inset; the default bottom reads the home-indicator inset.

Top (size=20) and bottom (size=32)

Content

Explicit size Override ​

size accepts plain numbers (px) or any CSS length (1rem / 24px / calc(...)) and writes --oas-safe-area-size; removing it restores the env(...) fallback.

size=1.5rem (24px)

Combined with StatusBar ​

A typical mobile page has the status-bar spacer at the top, the safe-area spacer at the bottom, and business content in between:

StatusBar + content + SafeArea skeleton

9:41
Business content

API ​

oas-safe-area ​

Attributes ​

AttributeDescriptionTypeDefault
positionPlacement direction: bottom (default, home-indicator area) / top (notch area)——
sizeHeight override: plain numbers are px, CSS lengths are accepted (1rem / 24px / calc(...)); defaults to env(safe-area-inset-*) (0 when unsupported)string—

Slots ​

NameDescription
defaultDecorative content (optional, e.g. a status dot); do not put page content here

CSS Variables ​

CSS VariableDescriptionDefault
--oas-safe-area-sizeHeight override (the size attribute writes the same variable)var(--oas-safe-area-inset)

Released under the MIT OR Apache-2.0 License.