# Spoiler dust

> Hidden text and photos in chat and reviews sit under shimmering particle dust that drifts. A tap blows the dust away from the touch point to reveal the content, and tapping again hides it.

- Type: Component (special)
- Access: Arc Pro
- Page: https://uiarc.dev/components/spoiler-dust
- Markdown: https://uiarc.dev/components/spoiler-dust/markdown
- Source file: `registry/components/spoiler-dust/spoiler-dust.tsx`
- Dependencies: motion, lucide-react
- Keywords: special, motion, text, new, spoiler, hidden text, reveal, particles, dust, chat, review, blur, tap to reveal, sensitive, shimmer, telegram

## When to use

- Plot points, results, or endings in chat, reviews, and comments that readers should choose to see.
- Sensitive values shared in a conversation, such as a door code or a surprise, and photos that should not show at a glance.

## When not to use

- Use scratch-card for a reward reveal that should feel like a game, with progress and a single payoff.
- Use a password field or a masked value with a show button for credentials in forms.
- Avoid long passages; a spoiler is for a phrase or a single image, not whole paragraphs.

## Installation

Spoiler dust is part of Arc Pro. The live preview is public; the source and install command need Pro.

### CLI with a Pro token

1. Create a token in your account and set it in the environment (or `.env.local`). Never commit it.

```bash
export ARC_PRO_TOKEN=arc_pro_...
```

2. Add the Pro registry to `components.json`:

```json
{
  "registries": {
    "@uiarc": "https://uiarc.dev/r/{name}.json",
    "@uiarc-pro": {
      "url": "https://uiarc.dev/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${ARC_PRO_TOKEN}"
      }
    }
  }
}
```

3. Install:

```bash
npx shadcn@latest add @uiarc-pro/spoiler-dust
```

### Manual

Signed-in Pro members can copy the source from the Manual tab on the docs page.

- Plans: https://uiarc.dev/pricing
- Create a Pro token: https://uiarc.dev/account#pro-access
- Setup guide: https://uiarc.dev/docs/ai#pro-access

## Usage

```tsx
import { Spoiler, SpoilerDust } from "@/components/arc/spoiler-dust/spoiler-dust";

export function Review() {
  return <SpoilerDust>
    <p>
      Slow first act, then it never lets go. The twist that <Spoiler label="twist">the narrator was the lighthouse keeper all along</Spoiler> reframes every chapter.
    </p>
  </SpoilerDust>;
}
```

## API reference

### SpoilerDust

A scope for spoilers in chat, reviews, and comments. Everything marked with Spoiler inside it sits under a fine shimmering dust that drifts and twinkles in place and parts around the pointer like sand. A tap blows the dust away from the touch point: grains fly outward and fade while the hidden words come back in a wave from where the finger landed, and a frosted veil over a photo opens as a soft circle from the same point. Tapping a revealed spoiler settles the dust back over it. Without children it renders a sample conversation with a hidden photo, door code, gift, and time, a revealed count, and a Hide all button.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `children` | `ReactNode` | – | Your own content with Spoiler elements anywhere inside it. Leave it out to render the sample conversation. |
| `density` | `number` | `1` | Multiplies how many dust grains cover each spoiler, from about 0.4 to 1.6. |
| `speed` | `number` | `1` | Multiplies how fast the dust drifts and twinkles. |
| `paused` | `boolean` | `false` | Freezes the drift and twinkle. Reveals, hides, and the pointer still move the dust. |
| `accent` | `string` | – | Color of your own messages in the sample conversation. Defaults to the accent. |
| `className` | `string` | – | Extra class on the root element. |
| `style` | `CSSProperties` | – | Inline styles on the root element. |

### Spoiler

A hidden run of text, or with media a hidden block such as a photo. It must sit inside SpoilerDust, which draws its dust. Text keeps its place in the line, so hiding and revealing never reflows the message.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `children` | `ReactNode` | – | The hidden content: a few words inline, or a block such as an image when media is set. |
| `revealed` | `boolean` | – | Controlled revealed state. Changing it from outside plays the reveal or hide from the center of the spoiler. |
| `defaultRevealed` | `boolean` | `false` | Initial state when uncontrolled. |
| `onRevealedChange` | `(revealed: boolean) => void` | – | Called with the new state when someone taps, clicks, or presses Enter or Space on the spoiler. |
| `media` | `boolean` | `false` | Covers a block, such as an image, with a frosted veil under the dust instead of hiding words. Give it a size or aspect ratio and a border radius with className. |
| `label` | `string` | `"spoiler"` | What is hidden, used as "Reveal <label>" for the accessible name and in announcements, for example "door code" or "ending". |
| `className` | `string` | – | Extra class on the spoiler element. |
| `style` | `CSSProperties` | – | Inline styles on the spoiler element. |

## Accessibility

- Each spoiler is a toggle button (role="button" with aria-pressed) reached with Tab. Enter or Space reveals it from its center, and pressing again hides it.
- While hidden, the content is hidden from assistive tech and the button is named "Reveal <label>", so a screen reader never reads the spoiler by accident. Once revealed, the name comes from the content itself, including an image's alt text.
- A polite live region announces each change, such as "Door code revealed", and changes made together, such as Hide all, as one sentence.
- Hidden text cannot be selected or copied. The revealed count in the sample is written out, so state never depends on the dust alone.
- Pointer focus draws no ring; keyboard focus shows Arc's shared focus ring. Keyboard focus tints the spoiler's background, and a focused photo darkens its veil slightly.

## Motion

- One canvas over the scope and one rAF loop draw every grain of dust from typed arrays, in a few alpha batches per spoiler. React only renders when a spoiler is toggled.
- Hidden dust drifts inside each line box and bounces off its edges, and every grain twinkles at its own rate. Grains near the pointer are pushed away and dragged along by its velocity, then spring back with a soft wobble.
- A reveal travels as a wave from the touch point. Each grain lets go when the wave reaches it and flies straight away from that point with drag, fading as it goes. Words fade and unblur on the same timing, and a photo's frosted veil opens as a soft edged circle the loop writes as a mask each frame.
- Hiding runs the wave the other way: fresh dust settles in from the tap point outward, each grain sliding a few pixels into place, while the words fade out quickly and the veil closes over the photo in a growing circle.
- The loop sleeps when nothing is hidden or moving, when the component is off screen, and when the tab is hidden. Reduced motion shows still dust and reveals or hides instantly.

## Responsive behavior

- Text spoilers wrap with the line and the dust follows every line box, so they work at any width. The canvas resizes with the scope and redraws the dust on resize.
- The sample conversation uses container queries: bubbles take up to 86 percent of a narrow container and 74 percent of a wide one.
- Pointer stirring is for mouse and pen; on touch a tap reveals, and vertical swipes still scroll the page.

## Performance

- Dust is capped per spoiler by area, and grains are drawn as tiny squares in eight alpha batches, so a busy thread stays well inside a frame.
- Layout is read once per resize, theme change, or toggle, never per frame. The veil's backdrop blur is static; only its mask changes during a reveal.

## Notes for AI

- Wrap the whole thread, review list, or comment section in one SpoilerDust, not each message; a single scope shares one canvas and one loop.
- Give every Spoiler a short label that says what is hidden without spoiling it, such as "ending", "price", or "venue photo".
- For photos, pass media and size the Spoiler with an aspect ratio and radius; the veil and dust follow its rounded corners.
- Control revealed from state to build Hide all or Reveal all actions, as the sample conversation does.

## Related

- [Chat thread](https://uiarc.dev/components/chat-thread/markdown): A chat thread with grouped messages, reactions, read receipts, typing, and a composer with attachments.
- [Comment thread](https://uiarc.dev/components/comment-thread/markdown): Threaded comments with replies, reactions, mentions, inline edit, and resolve.
- [Text reveal](https://uiarc.dev/components/text-reveal/markdown): Reveal a short piece of content with restrained motion.

## Also in playful

- [Sticker peel](https://uiarc.dev/components/sticker-peel/markdown): Peel stickers off a surface with a real curl, move them around, and stick them back down.
- [Ticket tear](https://uiarc.dev/components/ticket-tear/markdown): Pull a ticket stub and it tears along the perforation hole by hole, then drops away.
- [Page curl](https://uiarc.dev/components/page-curl/markdown): A small magazine you read by dragging page corners, with a real fold, lit curl, and flick to turn.
- [Orbit logos](https://uiarc.dev/components/orbit-logos/markdown): An integrations showcase with brand logos orbiting your product mark on tilted rings. Hover or focus one to rest the orbit, draw a connection, and see what it does.
- [Prize wheel](https://uiarc.dev/components/prize-wheel/markdown): A referral or promo prize wheel you flick to spin, with real angular momentum, a flexible pointer that ticks against each peg, weighted segments set by the host, a slow suspenseful settle, and the won segment lifting into a reward card with a copyable code.

## Guidance for AI tools

Spoiler dust: Hidden text and photos in chat and reviews sit under shimmering particle dust that drifts. A tap blows the dust away from the touch point to reveal the content, and tapping again hides it. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://uiarc.dev/llms.txt
