media-fullscreen-button
A button component for entering and exiting fullscreen mode
Anatomy
<FullscreenButton /><media-fullscreen-button></media-fullscreen-button>Behavior
Toggles fullscreen mode. Detects platform support through availability — when fullscreen is "unsupported", the toggle does nothing.
Styling
You can style the button based on fullscreen state:
/* In fullscreen */
media-fullscreen-button[data-fullscreen] {
background: red;
}Consider hiding the button when unsupported:
media-fullscreen-button[data-availability="unsupported"] {
display: none;
}Accessibility
Renders a <button> with an automatic aria-label: “Enter fullscreen” or “Exit fullscreen”. Override with the label prop. Keyboard activation: Enter / Space.
Examples
Basic Usage
import { createPlayer, FullscreenButton, features } from '@videojs/react';
import { Video } from '@videojs/react/video';
import './BasicUsage.css';
const Player = createPlayer({ features: [...features.video] });
export default function BasicUsage() {
return (
<Player.Provider>
<Player.Container className="react-fullscreen-button-basic">
<Video
src="https://stream.mux.com/lhnU49l1VGi3zrTAZhDm9LUUxSjpaPW9BL4jY25Kwo4/highest.mp4"
autoPlay
muted
playsInline
loop
/>
<FullscreenButton
className="react-fullscreen-button-basic__button"
render={(props, state) => <button {...props}>{state.fullscreen ? 'Exit Fullscreen' : 'Fullscreen'}</button>}
/>
</Player.Container>
</Player.Provider>
);
}
.react-fullscreen-button-basic {
position: relative;
}
.react-fullscreen-button-basic video {
width: 100%;
}
.react-fullscreen-button-basic__button {
padding-block: 8px;
position: absolute;
bottom: 10px;
right: 10px;
background: rgba(255, 255, 255, 0.7);
backdrop-filter: blur(10px);
color: black;
border: 1px solid rgba(255, 255, 255, 0.3);
border-radius: 9999px;
padding-inline: 20px;
cursor: pointer;
}
<video-player class="html-fullscreen-button-basic">
<video
src="https://stream.mux.com/lhnU49l1VGi3zrTAZhDm9LUUxSjpaPW9BL4jY25Kwo4/highest.mp4"
autoplay
muted
playsinline
loop
></video>
<media-fullscreen-button class="html-fullscreen-button-basic__button">
<span class="show-when-fullscreen">Exit Fullscreen</span>
<span class="show-when-not-fullscreen">Fullscreen</span>
</media-fullscreen-button>
</video-player>
.html-fullscreen-button-basic {
display: block;
position: relative;
}
.html-fullscreen-button-basic video {
width: 100%;
}
.html-fullscreen-button-basic__button {
padding-block: 8px;
position: absolute;
bottom: 10px;
right: 10px;
background: rgba(255, 255, 255, 0.7);
backdrop-filter: blur(10px);
color: black;
border: 1px solid rgba(255, 255, 255, 0.3);
border-radius: 9999px;
padding-inline: 20px;
cursor: pointer;
}
.html-fullscreen-button-basic__button .show-when-fullscreen {
display: none;
}
.html-fullscreen-button-basic__button .show-when-not-fullscreen {
display: none;
}
.html-fullscreen-button-basic__button[data-fullscreen] .show-when-fullscreen {
display: inline;
}
.html-fullscreen-button-basic__button:not([data-fullscreen]) .show-when-not-fullscreen {
display: inline;
}
import '@videojs/html/video/player';
import '@videojs/html/ui/fullscreen-button';
API Reference
Props
| Prop | Type | Default | |
|---|---|---|---|
disabled | boolean | false | |
| |||
label | string | function | '' | |
| |||
State
State is accessible via the
render, className, and style props.
State is reflected as data attributes for CSS styling.
| Property | Type | |
|---|---|---|
availability | 'available' | 'unavailable' | 'unsupported' | |
| ||
fullscreen | boolean | |
| ||
Data attributes
| Attribute | Description |
|---|---|
data-fullscreen | Present when fullscreen mode is active. |
data-availability | Indicates fullscreen availability (available or unsupported). |