A compact, accessible before‑and‑after comparison slider with colored panels on a dark background.
★ 0 community votes · Safety scan passed · Sandboxed previewBefore-After Slider is an interface component generated on MorphCanvas, an infinite AI workspace that turns written intent into reviewable HTML, CSS, and JavaScript widgets. This component passed MorphCanvas’s automated safety scan, which checks for unsafe patterns such as external network calls, storage access, inline event handlers, and code execution, and it is rendered here inside a sandboxed preview frame.
A creator described the result they wanted, MorphCanvas routed the request through its AI provider chain with automatic failover, scanned the generated code, and published the reviewed component to the public library. You can build and publish your own components on the MorphCanvas canvas.
How would you characterize this AI-generated component for your projects?
Select an evaluation tag above to record your vote.
<div id="slider" class="slider" role="region" aria-label="Before and after comparison" style="width:100%;max-width:600px;margin:auto;">
<div class="panel before" aria-hidden="true"></div>
<div class="panel after" aria-hidden="true"></div>
<div class="handle" role="slider" tabindex="0" aria-valuemin="0" aria-valuemax="100" aria-valuenow="50" aria-label="Adjust comparison" style="position:absolute;left:50%;top:0;bottom:0;width:4px;background:#fff;cursor:col-resize;transform:translateX(-50%);"></div>
</div>
body{background:#121212;color:#fff;font-family:sans-serif;margin:0;padding:20px} .slider{position:relative;height:300px;background:#333;border-radius:8px;overflow:hidden} .panel{position:absolute;top:0;bottom:0;left:0;right:0} .before{background:#4a90e2} .after{background:#e94e77;clip-path:inset(0 0 0 50%)} .handle{outline:none} .handle:focus{box-shadow:0 0 0 3px #fff}
(function(){const slider=document.getElementById('slider'),handle=slider.querySelector('.handle'),after=slider.querySelector('.after'),max=slider.clientWidth;let dragging=false;function update(pos){let pct=pos/max*100;pct=Math.min(100,Math.max(0,pct));after.style.clipPath=`inset(0 0 0 ${pct}%)`;handle.style.left=`${pct}%`;handle.setAttribute('aria-valuenow',pct.toFixed(0));}handle.addEventListener('pointerdown',e=>{dragging=true;handle.setPointerCapture(e.pointerId);});document.addEventListener('pointermove',e=>{if(dragging){update(e.clientX-slider.getBoundingClientRect().left);}});document.addEventListener('pointerup',e=>{dragging=false;});handle.addEventListener('keydown',e=>{if(e.key==='ArrowLeft'||e.key==='ArrowRight'){let step=5;let pct=parseInt(handle.getAttribute('aria-valuenow'));pct+=e.key==='ArrowRight'?step:-step;update(slider.clientWidth*pct/100);e.preventDefault();}});})();