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(...)is0— usesizeto set an explicit height for demos or fallbacks
Basic Usage
Bottom safe area (size=24 simulates the gesture area)
Top / Bottom
position="top" reads the top notch inset; the default bottom reads the home-indicator inset.
Top (size=20) and bottom (size=32)
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
API
oas-safe-area
Attributes
| Attribute | Description | Type | Default |
|---|---|---|---|
position | Placement direction: bottom (default, home-indicator area) / top (notch area) | — | — |
size | Height override: plain numbers are px, CSS lengths are accepted (1rem / 24px / calc(...)); defaults to env(safe-area-inset-*) (0 when unsupported) | string | — |
Slots
| Name | Description |
|---|---|
| default | Decorative content (optional, e.g. a status dot); do not put page content here |
CSS Variables
| CSS Variable | Description | Default |
|---|---|---|
--oas-safe-area-size | Height override (the size attribute writes the same variable) | var(--oas-safe-area-inset) |