Web Components API

Beautiful spoiler effects

Framework-agnostic web component with Telegram-inspired particle animations. Drop it into React, Vue, Svelte, or vanilla JavaScript in seconds.

App.tsx
import 'spoilerjs/spoiler-span';

export default function App() {
  return (
    <h1>
      Beautiful spoiler effects
    </h1>
  );
}

See it in action

Here are a few example uses. Click any spoiler to reveal the content.

๐Ÿ’ฌ
# spoiler-chat
Team discussion
A
Alex Today at 2:34 PM
Just finished the season finale! The twist with the villain being the hero's brother was insane! ๐Ÿคฏ
S
Sarah Today at 2:35 PM
Thanks for using spoiler tags! I'm only on episode 3 ๐Ÿ˜…
M
Mike Today at 2:36 PM
No worries! Click to reveal when you're ready ๐Ÿ‘
H2

Hades II

โ˜… 9.5
Roguelike Action Indie

Supergiant Games โ€ข 2025 โ€ข PC

โš  Review (Contains Spoilers)

A stunning sequel that expands on everything that made the original great. Playing as Melinoรซ, you discover that Chronos has escaped the Underworld and taken over, imprisoning Hades and forcing you to rally allies to stop time itself. The expanded combat system, gorgeous art, and Darren Korb's music make this an instant classic.

๐Ÿ’ณ
NeoBank
Premium Account
VIRTUAL CARD
๐Ÿ’Ž
4532 1234 5678 9010
VALID THRU
12/25
CVV
123
VISA
AVAILABLE BALANCE
$12,450.00
+2.5% this month
๐Ÿ“˜
API Reference
v3.2.1

Authentication

Authenticate your API requests using Bearer tokens. Include your API key in the Authorization header for all requests.

bash
curl -X GET "https://api.example.com/v1/data" \
  -H "Authorization: Bearer SECRET_KEY"
โš ๏ธ
Security Notice: Never expose your API keys in public repositories or client-side code.

Features

Built for developers who value simplicity and performance

๐ŸŒธ

Looks Pretty

Beautiful particle effects that enhance your UI without overwhelming it. Subtle yet engaging.

๐ŸŽฏ

Zero Config

Works out of the box. Just import and use. Sensible defaults with full customization when you need it.

๐Ÿ”Œ

Framework Agnostic

Built on Web Components standard. Works seamlessly with React, Vue, Svelte, Angular, or vanilla JS.

๐ŸŽจ

Customizable

Control particle density, velocity, lifetime, and reveal animations through simple HTML attributes.

๐Ÿ“ฑ

Mobile Optimized

Touch-friendly interactions with responsive particle scaling. Perfect on phones, tablets, and desktops.

๐ŸŒ™

Theme Aware

Automatically adapts particles to match your text color. Works beautifully in light and dark themes.

Quick Start

Get up and running in under 60 seconds

๐Ÿ“ฆ

NPM

For modern build tools

npm install spoilerjs
๐Ÿ”—

CDN

For quick usage without installation

<script
  type="module"
  src="https://unpkg.com/spoilerjs/dist/components/spoiler-span.js">
</script>

Examples

import 'spoilerjs/spoiler-span';

export default function App() {
  return (
    <div>
      <h1>Spoiler Alert!</h1>
      <p>
        The truth is <spoiler-span>hidden</spoiler-span>
      </p>
    </div>
  );
}

Customization Attributes

scale number

Particle size multiplier

Default: 1

density number

Particles per 100pxยฒ

Default: 8

min-velocity number

Min particle speed (px/frame)

Default: 0.01

max-velocity number

Max particle speed (px/frame)

Default: 0.05

particle-lifetime number

Duration in frames (60fps)

Default: 120

reveal-duration number

Fade-in time (ms)

Default: 500

monitor-position boolean

Enable RAF loop for tracking hover/transform effects. Better if you keep it disabled unless necessary.

Default: false