Fullscreen Control Web Component Demo

Fullscreen controls for video and embedded content. See the README for installation and API documentation.

Use the fullscreen button, then Escape or the browser’s fullscreen controls to return. Buttons overlay the top-right of the media. With enlarged labels, the demo’s media area grows to keep the overlay inside it and clear of native playback controls.

Before JavaScript loads, or if enhancement fails, videos retain native controls and the embedded presentation stays readable. Browser permissions and support can limit fullscreen. Follow the sample link if playback fails.

Video with native controls

Author controls in HTML for the no-JavaScript fallback. This local, silent clip has no speech or audio.

<fullscreen-control>
  <video src="./sample.webm" controls
    width="320" height="180"
    aria-label="Moving circle">
    <a href="./sample.webm">Open the sample clip</a>
  </video>
</fullscreen-control>
<p>Silent clip: a circle moves left to right
  across a rectangle; no audio.</p>

Silent clip: a circle moves left to right across a rectangle; no audio. Open the sample clip.

Embedded presentation

A local text presentation avoids third-party loading and tracking. Give every iframe a title. For a remote embed, check the provider’s fullscreen permissions and retain a direct link.

<fullscreen-control id="iframe-demo">
  <iframe src="./frame.html"
    title="Product presentation"
    width="320" height="180"
    allow="fullscreen" allowfullscreen></iframe>
</fullscreen-control>
<a href="./frame.html">Read the presentation</a>

Read the presentation outside the frame.

Localized button text

Author button-text in the content language. With no button-label, visible text is also the accessible name.

<fullscreen-control lang="ja"
  button-text="全画面表示">
  <video src="./sample.webm" controls
    aria-label="円の動き"></video>
</fullscreen-control>

音声のない動画:四角形の中を円が左から右へ移動します。

Media names in button labels

{name} uses the first nonempty aria-label or title on the media, not its full computed accessible name. Name and ID changes update the button automatically.

If you add button-label, include the visible wording in the accessible name to support speech input.

<fullscreen-control
  button-text="View {name} fullscreen">
  <video src="./sample.webm" controls
    aria-label="Moving circle"></video>
</fullscreen-control>

Silent clip: a circle moves left to right across a rectangle; no audio.

Icon-only fullscreen button

The diagonal two-headed arrow opens the clip in fullscreen. Use button-text for the symbol and button-label for an authored accessible name. The name describes the action rather than announcing the arrow character. The native focus ring remains.

<div class="demo">
<fullscreen-control class="icon-only"
  button-text="⤢"
  button-label="View {name} fullscreen">
  <video src="./sample.webm" controls
    width="320" height="180"
    aria-label="Moving circle"></video>
</fullscreen-control>
</div>

<style>
.demo .icon-only > button {
  inline-size: 2.75rem;
  padding: 0.25rem;
  font-size: 1.75rem;
  line-height: 1;
}
</style>

The diagonal arrow opens the clip in fullscreen.

Silent clip: a circle moves left to right across a rectangle; no audio.

Fullscreen events

fullscreen-control:enter and fullscreen-control:exit report observed fullscreen changes. The log keeps the last five entries. It is not a live region; native fullscreen changes already affect browser feedback.

<fullscreen-control id="event-demo">
  <video src="./sample.webm" controls
    aria-label="Moving circle"></video>
</fullscreen-control>
<script>
  const media = document.querySelector('#event-demo');
  media.addEventListener('fullscreen-control:enter',
    () => console.log('Entered fullscreen'));
  media.addEventListener('fullscreen-control:exit',
    () => console.log('Exited fullscreen'));
</script>

Silent clip: a circle moves left to right across a rectangle; no audio.

Latest fullscreen events:

Custom color pair

This opt-in red theme keeps its white foreground through hover. It does not replace native focus or opt out of forced-color adjustment. Check both foreground and background when adapting it.

.demo .custom-style > button {
  background: #a63232;
  color: #ffffff;
  border: 1px solid currentColor;
  border-radius: 1.25rem;
  font-weight: bold;
}
.demo .custom-style > button:hover {
  background: #8d2828;
}

Silent clip: a circle moves left to right across a rectangle; no audio.

API and browser limits

The light-DOM button controls the first nested video or iframe. Only the media enters fullscreen, not the surrounding component or this button. When entry came from the button, an observed exit returns focus to it. Programmatic entry does not request that focus return.

Use buttonText and buttonLabel or the matching attributes for labels. Use enterFullscreen(), exitFullscreen(), and toggleFullscreen() for scripted control; entry usually needs a user gesture.

The positioning hooks --fullscreen-control-button-inset-block-start and --fullscreen-control-button-inset-inline-end both default to 0.5rem. They position the default overlay. These demos use the same offsets in a shared grid cell so the button stays over the media while the media area can grow with enlarged labels.

Fullscreen failures are logged to the console, not shown by the component. Keep the media and direct links usable, and provide localized recovery instructions in your application. See the README for lifecycle and browser limitations.