useScreenSafeArea

Reactive env(safe-area-inset-*)

Get the safe area of the screen.

safe-area

Examples

Basic Usage

{
  "top": "0px",
  "right": "0px",
  "bottom": "0px",
  "left": "0px"
}

Basic Usage

Get the safe area of the screen.

Usage

In order to make the page to be fully rendered in the screen, the additional attribute viewport-fit=cover within viewport meta tag must be set firstly, the viewport meta tag may look like this:

<meta name="viewport" content="initial-scale=1, viewport-fit=cover">
<meta name="viewport" content="initial-scale=1, viewport-fit=cover">

API

const safeArea = useScreenSafeArea()
const safeArea = useScreenSafeArea()

Result

参数说明类型
safeArea安全区域Accessor<Area>

Area

参数说明类型
top顶部安全区域string
bottom底部安全区域string
left左侧安全区域string
right右侧安全区域string