FullscreenButton
Accessible fullscreen toggle button with keyboard support and state reflection
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;
}
/* Disabled (prop or feature unavailable) */
media-fullscreen-button[data-disabled] {
opacity: 0.5;
cursor: not-allowed;
} React renders a <button> element. Add a className to style it:
/* In fullscreen */
.fullscreen-button[data-fullscreen] {
background: red;
}
/* Disabled (prop or feature unavailable) */
.fullscreen-button[data-disabled] {
opacity: 0.5;
cursor: not-allowed;
} When fullscreen is unsupported, the button receives a hidden attribute and is automatically hidden by the browser. When disabled (via the disabled prop or because the feature is not available), the button remains visible but receives data-disabled for styling (e.g., reduced opacity).
In React, the button returns null when unsupported — no CSS needed. When disabled (via the disabled prop or because the feature is not available), the button remains visible with data-disabled for styling.
Accessibility
Renders a <button> with an automatic aria-label: “Enter fullscreen” or “Exit fullscreen”. Override with the label prop. Keyboard activation: Enter / Space. Both disabled and unavailable states set aria-disabled="true" so screen readers announce the button as non-interactive.
Examples
Basic Usage
import { createPlayer, FullscreenButton } from '@videojs/react';
import { Video, videoFeatures } from '@videojs/react/video';
const Player = createPlayer({ features: videoFeatures });
export default function BasicUsage() {
return (
<Player.Provider>
<Player.Container className="media-container">
<Video
src="https://stream.mux.com/BV3YZtogl89mg9VcNBhhnHm02Y34zI1nlMuMQfAbl3dM/highest.mp4"
autoPlay
muted
playsInline
loop
/>
<FullscreenButton
className="media-fullscreen-button"
render={(props, state) => <button {...props}>{state.fullscreen ? 'Exit Fullscreen' : 'Fullscreen'}</button>}
/>
</Player.Container>
</Player.Provider>
);
}
.media-container {
position: relative;
}
.media-container video {
width: 100%;
}
.media-fullscreen-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="video-player">
<media-container>
<video
src="https://stream.mux.com/BV3YZtogl89mg9VcNBhhnHm02Y34zI1nlMuMQfAbl3dM/highest.mp4"
autoplay
muted
playsinline
loop
></video>
<media-fullscreen-button class="media-fullscreen-button">
<span class="fullscreen">Exit Fullscreen</span>
<span class="not-fullscreen">Fullscreen</span>
</media-fullscreen-button>
</media-container>
</video-player>
.video-player {
display: block;
position: relative;
}
.video-player video {
width: 100%;
}
.media-fullscreen-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;
}
.media-fullscreen-button .fullscreen {
display: none;
}
.media-fullscreen-button .not-fullscreen {
display: none;
}
.media-fullscreen-button[data-fullscreen] .fullscreen {
display: inline;
}
.media-fullscreen-button:not([data-fullscreen]) .not-fullscreen {
display: inline;
}
import '@videojs/html/video/player';
import '@videojs/html/ui/fullscreen-button';
API Reference
Props
| Prop | Type | Default | Details |
|---|---|---|---|
disabled | boolean | false | |
| |||
label | string | function | '' | |
| |||
State
render, className, and style props.
| Property | Type | Details |
|---|---|---|
availability | 'available' | 'unavailable' | 'unsupp... | |
| ||
disabled | boolean | |
| ||
fullscreen | boolean | |
| ||
label | string | |
Data attributes
| Attribute | Type | Details |
|---|---|---|
data-fullscreen | ||
| ||
data-availability | 'available' | 'unavailable' | 'unsupp... | |
| ||
data-disabled | ||
| ||