FullscreenButton
A button component for entering and exiting fullscreen mode
Anatomy
<FullscreenButton /><media-fullscreen-button></media-fullscreen-button>Examples
Basic Usage
import { createPlayer, FullscreenButton, features, Video } from '@videojs/react';
import './BasicUsage.css';
const Player = createPlayer({ features: [...features.video] });
export default function BasicUsage() {
return (
<Player.Provider>
<Player.Container className="fullscreen-button-basic">
<Video
src="https://stream.mux.com/lhnU49l1VGi3zrTAZhDm9LUUxSjpaPW9BL4jY25Kwo4/highest.mp4"
autoPlay
muted
playsInline
loop
/>
<FullscreenButton
className="fullscreen-button-basic__button"
render={(props, state) => <button {...props}>{state.fullscreen ? 'Exit Fullscreen' : 'Fullscreen'}</button>}
/>
</Player.Container>
</Player.Provider>
);
}
.fullscreen-button-basic {
position: relative;
}
.fullscreen-button-basic video {
width: 100%;
}
.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="fullscreen-button-basic">
<video
src="https://stream.mux.com/lhnU49l1VGi3zrTAZhDm9LUUxSjpaPW9BL4jY25Kwo4/highest.mp4"
autoplay
muted
playsinline
loop
></video>
<media-fullscreen-button class="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>
.fullscreen-button-basic {
display: block;
position: relative;
}
.fullscreen-button-basic video {
width: 100%;
}
.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;
}
.fullscreen-button-basic__button .show-when-fullscreen {
display: none;
}
.fullscreen-button-basic__button .show-when-not-fullscreen {
display: none;
}
.fullscreen-button-basic__button[data-fullscreen] .show-when-fullscreen {
display: inline;
}
.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 | |
| ||