Skip to main content

Function: getSafeAreaInsets()

getSafeAreaInsets(): SafeAreaInsets

Defined in: rendering/utilities/get-safe-area-insets.ts:54

Reads the browser viewport's current safe-area insets (env(safe-area- inset-*)), in CSS pixels - there's no direct JS API for these, so this uses the standard technique of reading them back off a hidden probe element's computed padding. Safe to call every frame - the probe element is created once and reused, and reading computed style is cheap.

A browser with no notch/cutout (or that doesn't support env()) reads as all zeroes, so calling this unconditionally is always safe - no feature-detection needed.

Returns​

SafeAreaInsets

The current safe-area insets, in CSS pixels.