FrameworkStyle

Build your own UI component

Create custom player controls that read state, dispatch actions, and stay accessible.

Custom components subscribe to player state and dispatch actions, just like built-in controls.

You might not need a custom component

Before building from scratch, check if an existing approach covers your use case:

  • Change what a control renders — use the render prop on any built-in component. See UI components.
  • Restyle a control — use CSS custom properties and data attributes. See UI components.
  • Rearrange or remove controls — eject a skin and modify it. See Customize skins.

Build a custom component when you need new behavior, a new state display, or integration with an external system.

Use player state and actions

Each feature exposes state properties and actions. Common features:

State Actions Feature
paused, ended play(), pause() Playback
currentTime, duration seek() Time
volume, muted setVolume(), toggleMuted() Volume
fullscreen requestFullscreen(), exitFullscreen() Fullscreen

Browse the full list in the Features section of the sidebar.

Each feature also has an availability property ('available', 'unavailable', or 'unsupported') for hiding controls the platform does not support. See Features for details.

Access state and actions with usePlayer:

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

// Subscribe to state — re-renders only when selected values change
const paused = usePlayer((s) => s.paused);
const currentTime = usePlayer((s) => s.currentTime);

// Get the store for dispatching actions (does not subscribe)
const store = usePlayer();

await store.play();
store.setVolume(0.5);
store.seek(30);

Place your component in the player

Your component needs to be inside <Player.Provider> to access state. Place it inside <Player.Container> if it should also participate in fullscreen and respond to user activity:

<Player.Provider>
  <Player.Container>
    <VideoSkin>
      <Video src="video.mp4" />
    </VideoSkin>
    <SkipIntroButton />
  </Player.Container>
</Player.Provider>

Make it accessible

Use semantic HTML elements (<button>, not <div>), add ARIA attributes where needed, and support keyboard interaction.

Full example

A “skip intro” button that appears during the first 30 seconds of playback and seeks past the intro when clicked.

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

function SkipIntroButton() {
  const store = usePlayer();
  const currentTime = usePlayer((s) => s.currentTime);
  const paused = usePlayer((s) => s.paused);

  const visible = currentTime < 30 && !paused;

  return (
    <button
      className="skip-intro-button"
      onClick={() => store.seek(30)}
      aria-label="Skip intro"
      // `undefined` removes the attribute; `false` would render data-visible="false"
      data-visible={visible || undefined}
      tabIndex={visible ? 0 : -1}
    >
      Skip intro
    </button>
  );
}