npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@aarongustafson/fullscreen-control

v2.0.4

Published

A web component to add progressively enhance any video or iframe element to have fullscreen capabilities.

Readme

fullscreen-control Web Component

npm version Build Status

A web component to progressively enhance any video or iframe element with fullscreen capabilities.

Demo

Installation

npm install @aarongustafson/fullscreen-control

Usage

Option 1: Import the class and define manually

Import the class and define the custom element with your preferred tag name:

import { FullscreenControlElement } from '@aarongustafson/fullscreen-control';

customElements.define('my-custom-name', FullscreenControlElement);

Option 2: Auto-define the custom element (browser environments only)

Use the guarded definition helper to register the element when customElements is available:

import '@aarongustafson/fullscreen-control/define.js';

If you prefer to control when the element is registered, call the helper directly:

import { defineFullscreenControl } from '@aarongustafson/fullscreen-control/define.js';

defineFullscreenControl();

You can also include the guarded script from HTML:

<script src="./node_modules/@aarongustafson/fullscreen-control/define.js" type="module"></script>

Basic Example

<fullscreen-control>
  <video src="video.mp4"></video>
</fullscreen-control>

Or with an iframe:

<fullscreen-control button-text="View {name} fullscreen">
  <iframe src="https://example.com" title="Product teaser"></iframe>
</fullscreen-control>

TypeScript

This package ships bundled TypeScript definitions. Importing either @aarongustafson/fullscreen-control or @aarongustafson/fullscreen-control/fullscreen-control.js provides typed access to FullscreenControlElement along with its fullscreen-control:enter and fullscreen-control:exit events.

Accessibility

The component automatically manages focus for keyboard accessibility. When the fullscreen button is clicked to enter fullscreen mode, focus will automatically return to the button after exiting fullscreen, ensuring a seamless keyboard navigation experience. The control also links the button to the wrapped media via aria-controls, generating a unique id for the slotted element when it does not already have one.

Both button-text and button-label support the {name} placeholder. If the slotted video or iframe has an accessible name (via aria-label, title, or other native naming), {name} will be replaced with that value; otherwise it resolves to an empty string.

Changes to the slotted media's accessible name or id are observed automatically, ensuring the visible button text and its aria-controls attribute remain in sync even when those attributes are updated dynamically.

Attributes

| Attribute | Type | Default | Description | |-----------|------|---------|-------------| | button-text | string | "View fullscreen" | Visible text for the fullscreen button. Supports {name} to inject the slotted media's accessible name. | | button-label | string | "" (falls back to button-text) | Optional aria-label for the fullscreen button. Supports {name}. Only set this when the screen reader announcement should differ from the visible text; otherwise omit it so it mirrors button-text. |

Events

The component fires custom events that you can listen to:

| Event | Description | Detail | |-------|-------------|--------| | fullscreen-control:enter | Fired when entering fullscreen mode | CustomEvent | | fullscreen-control:exit | Fired when exiting fullscreen mode | CustomEvent |

Example Event Handling

const element = document.querySelector('fullscreen-control');

element.addEventListener('fullscreen-control:enter', (event) => {
  console.log('Entered fullscreen');
});

element.addEventListener('fullscreen-control:exit', (event) => {
  console.log('Exited fullscreen');
});

Methods

| Method | Description | |--------|-------------| | enterFullscreen() | Programmatically enter fullscreen mode | | exitFullscreen() | Programmatically exit fullscreen mode | | toggleFullscreen() | Toggle fullscreen mode on/off |

CSS Custom Properties

The component uses light DOM, so you can style the button directly using standard CSS selectors. Additionally, two CSS custom properties are available for positioning:

| Property | Default | Description | |----------|---------|-------------| | --fullscreen-control-button-inset-block-start | 0.5rem | Block-start (top) position of the button | | --fullscreen-control-button-inset-inline-end | 0.5rem | Inline-end (right in LTR) position of the button |

Example Styling

/* Style the button directly */
fullscreen-control button {
  background: #ff6b6b;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 20px;
}

/* Adjust button position */
fullscreen-control {
  --fullscreen-control-button-inset-block-start: 1rem;
  --fullscreen-control-button-inset-inline-end: 1rem;
}

Browser Support

This component uses modern web standards:

  • Custom Elements v1
  • Shadow DOM v1
  • ES Modules

For older browsers, you may need polyfills.

Development

# Install dependencies
npm install

# Run tests
npm test

# Run tests with coverage
npm run test:coverage

# Lint code
npm run lint

# Format code
npm run format

# View demo
open demo/index.html

License

MIT © Aaron Gustafson