StealThis .dev
Patterns Medium

Box Reveal

Content revealed by a colored box that slides across then exits, creating a dramatic wipe-reveal effect.

Open in Lab
css javascript vue svelte
Targets: TS JS HTML React Vue Svelte

Code

Box Reveal

A striking two-step wipe animation where a colored box slides in from one side to cover the area, then slides out the other direction to reveal the content underneath.

How it works

  1. Content starts hidden (opacity: 0) behind a pseudo-element
  2. When the element enters the viewport, the pseudo-element slides in from the left covering the area
  3. At the midpoint, the content becomes visible and the pseudo-element slides out to the right
  4. The result is a clean, dramatic reveal effect

Customization

  • Change the --box-color CSS variable to match your brand accent
  • Adjust --box-duration for faster or slower reveals
  • Use data-direction attribute for different slide directions
  • Stagger multiple reveals with data-delay

When to use it

  • Hero section headlines
  • Feature introductions
  • Section transitions
  • Any text or content that deserves dramatic emphasis