useFullscreen
Controls and tracks the fullscreen state of an element, with programmatic toggle support.
Controls and tracks the fullscreen state of an element, with programmatic toggle support.
Basic usage example to quickly see how the useFullscreen
works.
Given an element that you'd like to present in fullscreen mode (such as a <video>, <img>, for example), you can present it in fullscreen mode by calling its requestFullscreen()
method.
It's not guaranteed that the element will be put into full screen mode. If permission to enter full screen mode is granted, the returned Promise
will resolve and the element will receive a fullscreenchange
event to let it know that it's now in full screen mode. If permission is denied, the promise is rejected and the element receives a fullscreenerror
event instead. If the element has been detached from the original document, then the document receives these events instead.
Full working code example, including necessary markup and styles. You can copy and paste this code directly to start using the component immediately.