FrameworkStyle

FullscreenButton

A button component for entering and exiting fullscreen mode

Anatomy

<FullscreenButton />

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, Video } from '@videojs/react';

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>
  );
}

API Reference

Props

Prop Type Default
disabled boolean false
label string | function ''

State

State is accessible via the render, className, and style props.

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).
VideoJS