Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply VueUse composables in Vue 3/Nuxt projects to replace custom implementations with battle-tested utilities.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/useDeviceOrientation.md
1---2category: Sensors3---45# useDeviceOrientation67Reactive [DeviceOrientationEvent](https://developer.mozilla.org/en-US/docs/Web/API/DeviceOrientationEvent). Provide web developers with information from the physical orientation of the device running the web page.89## Usage1011```ts12import { useDeviceOrientation } from '@vueuse/core'1314const {15isAbsolute,16alpha,17beta,18gamma,19} = useDeviceOrientation()20```2122| State | Type | Description |23| ---------- | --------- | -------------------------------------------------------------------------------------------------------------------------- |24| isAbsolute | `boolean` | A boolean that indicates whether or not the device is providing orientation data absolutely. |25| alpha | `number` | A number representing the motion of the device around the z axis, express in degrees with values ranging from 0 to 360. |26| beta | `number` | A number representing the motion of the device around the x axis, express in degrees with values ranging from -180 to 180. |27| gamma | `number` | A number representing the motion of the device around the y axis, express in degrees with values ranging from -90 to 90. |2829You can find [more information about the state on the MDN](https://developer.mozilla.org/en-US/docs/Web/API/DeviceOrientationEvent#instance_properties).3031## Component Usage3233```vue34<template>35<UseDeviceOrientation v-slot="{ alpha, beta, gamma }">36Alpha: {{ alpha }}37Beta: {{ beta }}38Gamma: {{ gamma }}39</UseDeviceOrientation>40</template>41```4243## Type Declarations4445```ts46export interface UseDeviceOrientationOptions extends ConfigurableWindow {}47export interface UseDeviceOrientationReturn extends Supportable {48isAbsolute: ShallowRef<boolean, boolean>49alpha: Ref<number | null, number | null>50beta: Ref<number | null, number | null>51gamma: Ref<number | null, number | null>52}53/**54* Reactive DeviceOrientationEvent.55*56* @see https://vueuse.org/useDeviceOrientation57* @param options58*59* @__NO_SIDE_EFFECTS__60*/61export declare function useDeviceOrientation(62options?: UseDeviceOrientationOptions,63): UseDeviceOrientationReturn64```65