Files
stack/packages/mosaic/framework/skills/vueuse-functions/references/useScreenOrientation.md
T
fargo 1a822493ba format: apply repo prettier (3.8.1) to the folded skills tree
963 markdown files reformatted with the repository's pinned prettier so
pnpm format:check covers the folded tree like every other repo file.

The formatter's embedded-language pass also normalized code fences
(TS semicolons, closed HTML tags in examples, lowercased CSS hex colors,
one renumbered list that skipped an index). Alphanumeric token deltas vs
the fold commit were audited file-by-file; all are formatter-equivalent
markup normalizations plus the four sanitized skills.
2026-08-19 14:37:17 -05:00

2.4 KiB

category
category
Browser

useScreenOrientation

Reactive Screen Orientation API. It provides web developers with information about the user's current screen orientation.

Usage

import { useScreenOrientation } from '@vueuse/core';

const { isSupported, orientation, angle, lockOrientation, unlockOrientation } =
  useScreenOrientation();

To lock the orientation, you can pass an OrientationLockType to the lockOrientation function:

import { useScreenOrientation } from '@vueuse/core';

const { isSupported, orientation, angle, lockOrientation, unlockOrientation } =
  useScreenOrientation();

lockOrientation('portrait-primary');

and then unlock again, with the following:

import { useScreenOrientation } from '@vueuse/core';

const { unlockOrientation } = useScreenOrientation();
// ---cut---
unlockOrientation();

Accepted orientation types are one of "landscape-primary", "landscape-secondary", "portrait-primary", "portrait-secondary", "any", "landscape", "natural" and "portrait".

Screen Orientation API MDN

Type Declarations

export type OrientationType =
  | 'portrait-primary'
  | 'portrait-secondary'
  | 'landscape-primary'
  | 'landscape-secondary';
export type OrientationLockType =
  | 'any'
  | 'natural'
  | 'landscape'
  | 'portrait'
  | 'portrait-primary'
  | 'portrait-secondary'
  | 'landscape-primary'
  | 'landscape-secondary';
export interface ScreenOrientation extends EventTarget {
  lock: (orientation: OrientationLockType) => Promise<void>;
  unlock: () => void;
  readonly type: OrientationType;
  readonly angle: number;
  addEventListener: (
    type: 'change',
    listener: (this: this, ev: Event) => any,
    useCapture?: boolean,
  ) => void;
}
/**
 * Reactive screen orientation
 *
 * @see https://vueuse.org/useScreenOrientation
 *
 * @__NO_SIDE_EFFECTS__
 */
export declare function useScreenOrientation(options?: ConfigurableWindow): {
  isSupported: ComputedRef<boolean>;
  orientation: Ref<OrientationType | undefined, OrientationType | undefined>;
  angle: ShallowRef<number, number>;
  lockOrientation: (type: OrientationLockType) => Promise<void>;
  unlockOrientation: () => void;
};
export type UseScreenOrientationReturn = ReturnType<typeof useScreenOrientation>;