Skip to content

Before/After Wipe

A copy-paste image effects component in pure HTML & CSS. Zero dependencies, framework-agnostic, MIT-licensed.

Image EffectsHTMLCSSany framework

Copy into your project

HTML
<!-- Before/After Wipe -->
<figure class="nuda-ie2-compare" role="img" aria-label="Before and after photo comparison">
  <img class="nuda-ie2-compare__after" src="/your-image-after.jpg" alt="" aria-hidden="true" />
  <img class="nuda-ie2-compare__before" src="/your-image-before.jpg" alt="" aria-hidden="true" />
  <span class="nuda-ie2-compare__tag nuda-ie2-compare__tag--before" aria-hidden="true">BEFORE</span>
  <span class="nuda-ie2-compare__tag nuda-ie2-compare__tag--after" aria-hidden="true">AFTER</span>
  <span class="nuda-ie2-compare__handle" aria-hidden="true"></span>
</figure>
CSS
.nuda-ie2-compare {
  position: relative;
  width: 200px;
  height: 140px;
  border-radius: 10px;
  overflow: hidden;
  background: #0a0a0a;
  margin: 0;
}

.nuda-ie2-compare__after {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: saturate(1.15) contrast(1.05);
}

.nuda-ie2-compare__before {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: grayscale(100%) brightness(.85);
  clip-path: inset(0 0 0 0);
  animation: nuda-ie2-compare-wipe 6s ease-in-out infinite;
  will-change: clip-path;
}

.nuda-ie2-compare__handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  background: #e4ff54;
  box-shadow: 0 0 8px rgba(228,255,84,.6);
  transform: translateX(100px);
  animation: nuda-ie2-compare-handle 6s ease-in-out infinite;
  will-change: transform;
}

.nuda-ie2-compare__handle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e4ff54;
  transform: translate(-50%,-50%);
  box-shadow: 0 2px 6px rgba(0,0,0,.5);
}

.nuda-ie2-compare__tag {
  position: absolute;
  top: 6px;
  font: 700 8px ui-sans-serif,system-ui;
  letter-spacing: .08em;
  padding: 2px 6px;
  border-radius: 3px;
  color: #0a0a0a;
  background: #e4ff54;
}

.nuda-ie2-compare__tag--before {
  left: 6px;
}

.nuda-ie2-compare__tag--after {
  right: 6px;
  background: rgba(255,255,255,.85);
}

@keyframes nuda-ie2-compare-wipe {
  0%,100% {
    clip-path: inset(0 0 0 0);
  }
  50% {
    clip-path: inset(0 100% 0 0);
  }
}

@keyframes nuda-ie2-compare-handle {
  0%,100% {
    transform: translateX(200px);
  }
  50% {
    transform: translateX(0px);
  }
}

@media (prefers-reduced-motion:reduce) {
  .nuda-ie2-compare__before {
    animation: none !important;
    clip-path: inset(0 50% 0 0);
  }
  .nuda-ie2-compare__handle {
    animation: none !important;
    transform: translateX(100px);
  }
}

How to use Before/After Wipe

Paste the HTML where you need it and the CSS into a global stylesheet (or a <style> tag). Every class is prefixed nuda- so it never collides with Tailwind or your own styles. Tweak the CSS custom properties to match your design system.

Works in React, Vue, Svelte, Astro, Next.js, Nuxt, Laravel Blade, Django, Rails — or a single .html file. No npm install, no build step.

More image effects components

← Browse all NudaUI components