Web component / esm

<content-warning>

This page loads the component class from esm.sh and registers it manually. See the README.

The examples author hidden: their warning content stays hidden if JavaScript or the CDN fails. After loading, use the reveal button with Enter, Space, or a pointer.

import { ContentWarningElement } from 'https://esm.sh/@aarongustafson/content-warning@1.2.0/content-warning.js?bundle&target=es2022';

if (!customElements.get('content-warning')) {
  customElements.define('content-warning', ContentWarningElement);
}

Block Content Warning

Set type to describe the content before someone reveals it.

<content-warning type="violence spoilers" hidden>
  <p>This content contains graphic violence and spoilers.</p>
  <p>The scene describes a battle and its aftermath.</p>
</content-warning>

Inline Content Warning

Add inline to place a warning within a sentence.

<p>The character dies in
  <content-warning type="spoilers" inline hidden>episode 5</content-warning>.
</p>

The character dies in .