Skip to content

useOrientation ​

Hook that returns the current screen orientation

browser
test coverage
Last changed: last month

TIP

This hook uses window.screen.orientation browser api to provide enhanced functionality. Make sure to check for compatibility with different browsers when using this api

Installation ​

Library
CLI
Manual
typescript
import { useOrientation } from '@siberiacancode/reactuse';

Usage ​

typescript
const { angle, type } = useOrientation();

Demo ​

Api ​

Returns

UseOrientationReturn

Type declaration ​

typescript
export interface UseOrientationReturn {
  /** The current screen orientation angle */
  angle: number;
  /** The screen orientation type */
  type: OrientationType;
}

Source ​

Source • Demo

Contributors ​

D
debabin
debabin
B
babin
babin
H
hywax
hywax

Released under the MIT License.