Skip to content
FrameworkStyle

FullscreenButton

Accessible fullscreen toggle button with keyboard support and state reflection

Import

import { FullscreenButton } from '@videojs/react';

Anatomy

<FullscreenButton />

Behavior

Toggles fullscreen mode. The button derives two state hooks from availability:

  • disabled (true until fullscreen is available, or when the disabled prop is set) — sets aria-disabled="true" and data-disabled. A prop-disabled, available button stays focusable but does not activate.
  • hidden (true while fullscreen is "unavailable" or "unsupported") — applies the native HTML hidden attribute on the custom element; the React component returns null.

Styling

You can style the button based on fullscreen state:

React renders a <button> element. Add a className to style it:

/* In fullscreen */
.fullscreen-button[data-fullscreen] {
  background: red;
}

/* Non-interactive (disabled prop) */
.fullscreen-button[data-disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

The button remains hidden until fullscreen is available. The HTML element receives the native hidden attribute, and the React component returns null. No extra CSS is required.

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 { Container, createPlayer, FullscreenButton } from '@videojs/react';
import { Video, videoFeatures } from '@videojs/react/video';

const { Player } = createPlayer({ features: videoFeatures });

export default function BasicUsage() {
  return (
    <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>}
        />
      </Container>
    </Player>
  );
}

API Reference

Props

PropTypeDefaultDetails
disabledbooleanfalse
labelobject''

State

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

PropertyTypeDetails
fullscreenboolean
label{ key: string; text: string } | string
availabilityMediaFullscreenState['fullscreenAvailability']
disabledboolean
hiddenboolean

Data attributes

AttributeTypeDetails
data-fullscreen
data-availabilityMediaFullscreenState['fullscreenAvailability']
data-disabled
data-hidden