react-native-spoiler-view

Telegram-style spoiler effect for React Native. Tap to reveal content with animated particle burst.

Demo Demo

Installation

npm install react-native-spoiler-view

Peer Dependencies

npm install @shopify/react-native-skia react-native-reanimated react-native-gesture-handler

Setup: Skia · Reanimated · Gesture Handler

Usage

Basic

import { SpoilerView } from 'react-native-spoiler-view';

<SpoilerView>
  <Text>This is a secret message!</Text>
</SpoilerView>

Controlled

const [revealed, setRevealed] = useState(false);

<SpoilerView
  revealed={revealed}
  onReveal={() => setRevealed(true)}
>
  <Text>Hidden until revealed</Text>
</SpoilerView>

<Button title="Reveal" onPress={() => setRevealed(true)} />

Custom Config

<SpoilerView
  config={{
    particleCount: 300,
    particleColor: 'rgba(255, 100, 100, 1)',
    revealDuration: 400,
  }}
>
  <Image source={secretImage} />
</SpoilerView>

Props

PropTypeDefaultDescription
childrenReactNoderequiredContent to hide
revealedbooleanControlled reveal state
enabledbooleantrueEnable tap gesture
onReveal() => voidCalled when revealed
onHide() => voidCalled when hidden
configSpoilerConfigCustomize appearance
styleViewStyleContainer style

Config

{
  particleCount: 200,
  particleDensity: 0.08,
  particleSizeRange: [0.4, 0.9],
  particleColor: 'rgba(80, 80, 80, 1)',
  overlayColor: 'transparent',
  revealDuration: 600,
  burstSpeed: 150,
}