Voor en na vergelijken
Two photos of the same house on top of each other; drag the handle (or click anywhere) to see how much has changed. For renovation, painting, landscaping or cleaning. Clip-path without canvas, operable with mouse, touch and arrow keys through a proper slider role.
How to use it
- Paste the HTML where the components should appear.
- Add the CSS to your stylesheet. All classes are prefixed, so nothing clashes with your own styles.
- Add the JavaScript and call init() with the element that contains the HTML.
<!-- Voor en na vergelijken · © 2026 NedDev BV · NedDev Lab-licentie (gratis gebruik, niet doorverkopen) · neddev.com/nl/lab/gebruik/#licentie -->
<div class="jouw-container">
<div class="vna" style="--vna-p:50%">
<img class="vna__img" src="https://neddev.com/lab-media/site-renovatie-r3-2.webp" alt="Achtergevel voor de verbouwing, met oude kozijnen" draggable="false">
<img class="vna__img vna__img--na" src="https://neddev.com/lab-media/site-renovatie-r3-1.webp" alt="Dezelfde achtergevel na de verbouwing, met nieuwe pui" draggable="false">
<span class="vna__lab vna__lab--voor" aria-hidden="true">Voor</span><span class="vna__lab vna__lab--na" aria-hidden="true">Na</span>
<div class="vna__lijn"><span class="vna__greep" role="slider" tabindex="0" aria-label="Vergelijk voor en na" aria-valuemin="0" aria-valuemax="100" aria-valuenow="50" aria-valuetext="50 procent na"><svg viewBox="0 0 24 24" width="18" height="18" aria-hidden="true"><path d="M9 6l-5 6 5 6M15 6l5 6-5 6" fill="none" stroke="currentColor" stroke-width="2"/></svg></span></div>
</div>
</div>/* Voor en na vergelijken · © 2026 NedDev BV · NedDev Lab-licentie (gratis gebruik, niet doorverkopen) · neddev.com/nl/lab/gebruik/#licentie */
.vna{position:absolute;inset:0;overflow:hidden;touch-action:pan-y;cursor:ew-resize;user-select:none;-webkit-user-select:none;font-family:'Switzer',system-ui,sans-serif;background:#0a0a0a}
.vna__img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;pointer-events:none}
.vna__img--na{clip-path:inset(0 0 0 var(--vna-p))}
.vna__lijn{position:absolute;top:0;bottom:0;left:var(--vna-p);width:2px;margin-left:-1px;background:#fff}
.vna__greep{position:absolute;top:50%;left:50%;width:38px;height:38px;margin:-19px 0 0 -19px;border-radius:4px;background:#F5480F;color:#fff;display:grid;place-items:center;box-shadow:0 2px 10px rgba(0,0,0,.3);cursor:grab}
.vna__greep:focus-visible{outline:2px solid #fff;outline-offset:3px}
.vna.is-sleep .vna__greep{cursor:grabbing}
.vna__lab{position:absolute;top:10px;padding:4px 8px;border-radius:4px;background:rgba(10,10,10,.75);color:#fff;font-size:12px;font-weight:600;transition:opacity .2s}
.vna__lab--voor{left:10px}.vna__lab--na{right:10px}
.vna.is-l .vna__lab--voor,.vna.is-r .vna__lab--na{opacity:0}// Voor en na vergelijken · © 2026 NedDev BV · NedDev Lab-licentie (gratis gebruik, niet doorverkopen) · neddev.com/nl/lab/gebruik/#licentie
// root = het element waarin de HTML staat
function init(root){
const box = root.querySelector('.vna'); if (!box) return;
const greep = box.querySelector('.vna__greep');
let p = 50, actief = false;
const zet = v => {
p = Math.max(0, Math.min(100, v));
box.style.setProperty('--vna-p', p + '%');
greep.setAttribute('aria-valuenow', String(Math.round(p)));
greep.setAttribute('aria-valuetext', Math.round(100 - p) + ' procent na');
box.classList.toggle('is-l', p < 14); box.classList.toggle('is-r', p > 86);
};
const uitX = e => { const r = box.getBoundingClientRect(); return (e.clientX - r.left) / r.width * 100; };
box.addEventListener('pointerdown', e => { actief = true; box.setPointerCapture(e.pointerId); box.classList.add('is-sleep'); zet(uitX(e)); });
box.addEventListener('pointermove', e => { if (actief) zet(uitX(e)); });
const los = () => { actief = false; box.classList.remove('is-sleep'); };
box.addEventListener('pointerup', los); box.addEventListener('pointercancel', los);
greep.addEventListener('keydown', e => {
const stap = e.shiftKey ? 10 : 2; let n = null;
if (e.key === 'ArrowLeft' || e.key === 'ArrowDown') n = p - stap;
else if (e.key === 'ArrowRight' || e.key === 'ArrowUp') n = p + stap;
else if (e.key === 'Home') n = 0; else if (e.key === 'End') n = 100;
if (n !== null) { e.preventDefault(); zet(n); }
});
zet(50);
}
init(document.querySelector('.jouw-container'));
More components
Seen something you like?
Add it to your selection and send it over. We build your site around it, in your brand.
Get in touch →