Files
moeka-project/.agents/skills/vueuse-functions/references/useScreenSafeArea.md
T
2026-03-16 00:19:06 +08:00

1.3 KiB

category
category
Browser

useScreenSafeArea

Reactive env(safe-area-inset-*)

image

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" />

Then we could use useScreenSafeArea in the component as shown below:

import { useScreenSafeArea } from '@vueuse/core'

const {
  top,
  right,
  bottom,
  left,
} = useScreenSafeArea()

For further details, you may refer to this documentation: Designing Websites for iPhone X

Component Usage

<template>
  <UseScreenSafeArea top right bottom left>
    content
  </UseScreenSafeArea>
</template>

Type Declarations

export interface UseScreenSafeAreaReturn {
  top: ShallowRef<string>
  right: ShallowRef<string>
  bottom: ShallowRef<string>
  left: ShallowRef<string>
  update: () => void
}
/**
 * Reactive `env(safe-area-inset-*)`
 *
 * @see https://vueuse.org/useScreenSafeArea
 */
export declare function useScreenSafeArea(): UseScreenSafeAreaReturn