useFullscreen
Manages fullscreen state for a target DOM element (or document.documentElement) with vendor prefix support.
Loading preview...
The useFullscreen hook enters, exits, and toggles fullscreen mode for a target DOM element (defaulting to document.documentElement when no target is provided), handling standard and vendor-prefixed Fullscreen APIs automatically.
Installation
Usage
Examples
Fullscreen Media Player Container
Pass a container RefObject to toggle fullscreen on a specific element rather than the entire page.
Fullscreen Document Mode
Omit the target argument (or pass undefined) to enter and exit fullscreen on document.documentElement.
API Reference
UseFullscreenOptions
Lifecycle callbacks for fullscreen transitions and errors.
Property
Specification
onEnter?function
Callback fired when fullscreen mode is entered
Full Signature
Parameters
(onExit?function
Callback fired when fullscreen mode is exited
Full Signature
Parameters
(onError?function
Callback fired if entering or exiting fullscreen fails
Full Signature
Parameters
(errorunknownUseFullscreenReturn
Fullscreen state and control methods returned by the hook.
Property
Specification
isFullscreenunion
Whether the target element (or document) is currently in fullscreen mode
Full Signature
isSupportedunion
Whether the Fullscreen API is supported in the current browser
Full Signature
enterfunction
Requests fullscreen mode for the target element
Full Signature
exitfunction
Exits fullscreen mode
Full Signature
togglefunction
Toggles fullscreen mode on or off
Full Signature