Media Card Hover Scrub
Move across a video card to scrub through its preview frames with a progress bar and time, or use the arrow keys.
AI prompt
Clean UI mockup of a video grid card: a 16:9 thumbnail showing a sunrise over hills with a thin white progress bar along the bottom edge filled to about 40 percent, a small black timestamp pill 0:04 at the bottom right, below it a bold title Morning in the mountains and a grey line with channel and views, rounded corners, light theme, flat modern style. Negative: play button clutter, heavy shadows, text errors, device frames. Reduced motion: static design.About this pattern
Definition
A scrub preview lets people skim a video without opening it: the pointer position across the thumbnail picks a frame and a thin bar shows where they are. It saves clicks on video grids and gives a good sense of the content.
Purpose & UX principles
- Map horizontal position to a frame; show a progress bar and a timestamp.
- Use a handful of prepared frames, not live video decoding.
- Return to the poster frame when the pointer leaves.
- Support keyboard: focus the card and use the left and right arrows.
Interaction states
- One video card with eight frames; hover, drag or use arrow keys.
Motion specification
- Frames switch instantly with the pointer.
- Reduced motion: nothing animates; scrubbing still works as a direct control.
Responsive behaviour
- On touch devices allow dragging across the thumbnail, or show a tap to preview.
- Keep the title and metadata static so the card remains readable.
Code
<div class="bx"><div class="vc" id="vc" tabindex="0" role="slider" aria-label="Preview scrubber" aria-valuemin="0" aria-valuemax="7" aria-valuenow="0" aria-valuetext="Frame 1 of 8"><div class="fr" id="fr"><i class="sn"></i><i class="hl"></i></div><span class="tm" id="tm">0:00</span><b class="pb"><i id="pb"></i></b></div><div class="mt"><b>Morning in the mountains</b><span>Alpine Films · 1.2M views</span></div><p class="out">Move across the card, drag, or press the arrow keys.</p></div>:root{--bg:#F1F1EF;--surface:#fff;--surface-2:#F7F7F5;--line:#E0E0DC;--text:#171717;--muted:#6f6f6f;--accent:#171717;--accent-ink:#fff;--danger:#d92d20}
*{box-sizing:border-box;margin:0}
button{font:inherit;color:inherit;background:none;border:0;padding:0;cursor:pointer}a{color:inherit;text-decoration:none}ul,ol,p,h4{margin:0;padding:0}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.pre{display:flex;gap:5px;flex-wrap:wrap}.pre button{height:28px;padding:0 11px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:11px;cursor:pointer}
.pre button[aria-pressed=true]{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
.bx{width:min(330px,100%);display:grid;gap:9px}.rw{display:grid;gap:3px;font-size:11.5px;color:var(--muted)}.rw b{color:var(--text);font-weight:600}input[type=range]{width:100%;accent-color:#171717}
.out{font-size:12px;color:var(--muted);line-height:1.4}.out b{color:var(--text)}
button:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.vc{position:relative;aspect-ratio:16/9;border-radius:12px;overflow:hidden;cursor:ew-resize;touch-action:pan-y;outline-offset:2px}.fr{position:absolute;inset:0;background:linear-gradient(hsl(var(--h),52%,var(--l1)),hsl(calc(var(--h) + 20),58%,var(--l2)))}.fr i{position:absolute;display:block}.sn{left:var(--sx);bottom:var(--sy);width:26px;height:26px;margin-left:-13px;border-radius:50%;background:#fff6c8;box-shadow:0 0 22px 8px rgba(255,240,170,.6)}.hl{left:-5%;right:-5%;bottom:-18%;height:52%;background:#3a4a52;clip-path:polygon(0 100%,0 55%,22% 20%,42% 55%,64% 10%,100% 60%,100% 100%)}.tm{position:absolute;right:8px;bottom:12px;background:rgba(0,0,0,.75);color:#fff;font-size:10.5px;padding:1px 6px;border-radius:5px}.pb{position:absolute;left:0;right:0;bottom:0;height:3px;background:rgba(255,255,255,.3)}.pb i{display:block;height:100%;background:#fff;width:0}.mt{display:grid;gap:1px;font-size:13px}.mt span{font-size:11.5px;color:var(--muted)}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}const vc=document.getElementById('vc'),fr=document.getElementById('fr'),pb=document.getElementById('pb'),tm=document.getElementById('tm'),N=8;let cur=0;
function set(i){cur=Math.max(0,Math.min(N-1,i));const t=cur/(N-1);fr.style.setProperty('--h',(205-t*165).toFixed(0));fr.style.setProperty('--l1',(30+t*28)+'%');fr.style.setProperty('--l2',(52+t*20)+'%');fr.style.setProperty('--sx',(10+t*80)+'%');fr.style.setProperty('--sy',(24+Math.sin(t*Math.PI)*34)+'%');pb.style.width=(t*100)+'%';tm.textContent='0:0'+cur;vc.setAttribute('aria-valuenow',cur);vc.setAttribute('aria-valuetext','Frame '+(cur+1)+' of '+N);}
function at(e){const r=vc.getBoundingClientRect();set(Math.floor((e.clientX-r.left)/r.width*N));}
vc.addEventListener('pointermove',at);vc.addEventListener('pointerdown',at);vc.addEventListener('pointerleave',()=>set(0));vc.addEventListener('keydown',e=>{if(e.key==='ArrowRight'){e.preventDefault();set(cur+1);}else if(e.key==='ArrowLeft'){e.preventDefault();set(cur-1);}else if(e.key==='Home')set(0);else if(e.key==='End')set(N-1);});set(0);One complete HTML file. Save it and open it in a browser.
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Media Card Hover Scrub — demo</title>
<style>
:root{--bg:#F1F1EF;--surface:#fff;--surface-2:#F7F7F5;--line:#E0E0DC;--text:#171717;--muted:#6f6f6f;--accent:#171717;--accent-ink:#fff;--danger:#d92d20}
*{box-sizing:border-box;margin:0}
html,body{height:100%}body{background:var(--bg);color:var(--text);font:15px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',Inter,Roboto,sans-serif;-webkit-font-smoothing:antialiased}.stage{min-height:100%;display:grid;place-items:center;padding:24px}button,input,select,textarea{font-family:inherit}@media (prefers-reduced-motion:reduce){html{scroll-behavior:auto}}
button{font:inherit;color:inherit;background:none;border:0;padding:0;cursor:pointer}a{color:inherit;text-decoration:none}ul,ol,p,h4{margin:0;padding:0}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.pre{display:flex;gap:5px;flex-wrap:wrap}.pre button{height:28px;padding:0 11px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:11px;cursor:pointer}
.pre button[aria-pressed=true]{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
.bx{width:min(330px,100%);display:grid;gap:9px}.rw{display:grid;gap:3px;font-size:11.5px;color:var(--muted)}.rw b{color:var(--text);font-weight:600}input[type=range]{width:100%;accent-color:#171717}
.out{font-size:12px;color:var(--muted);line-height:1.4}.out b{color:var(--text)}
button:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.vc{position:relative;aspect-ratio:16/9;border-radius:12px;overflow:hidden;cursor:ew-resize;touch-action:pan-y;outline-offset:2px}.fr{position:absolute;inset:0;background:linear-gradient(hsl(var(--h),52%,var(--l1)),hsl(calc(var(--h) + 20),58%,var(--l2)))}.fr i{position:absolute;display:block}.sn{left:var(--sx);bottom:var(--sy);width:26px;height:26px;margin-left:-13px;border-radius:50%;background:#fff6c8;box-shadow:0 0 22px 8px rgba(255,240,170,.6)}.hl{left:-5%;right:-5%;bottom:-18%;height:52%;background:#3a4a52;clip-path:polygon(0 100%,0 55%,22% 20%,42% 55%,64% 10%,100% 60%,100% 100%)}.tm{position:absolute;right:8px;bottom:12px;background:rgba(0,0,0,.75);color:#fff;font-size:10.5px;padding:1px 6px;border-radius:5px}.pb{position:absolute;left:0;right:0;bottom:0;height:3px;background:rgba(255,255,255,.3)}.pb i{display:block;height:100%;background:#fff;width:0}.mt{display:grid;gap:1px;font-size:13px}.mt span{font-size:11.5px;color:var(--muted)}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}
</style></head>
<body><div class="stage">
<div class="bx"><div class="vc" id="vc" tabindex="0" role="slider" aria-label="Preview scrubber" aria-valuemin="0" aria-valuemax="7" aria-valuenow="0" aria-valuetext="Frame 1 of 8"><div class="fr" id="fr"><i class="sn"></i><i class="hl"></i></div><span class="tm" id="tm">0:00</span><b class="pb"><i id="pb"></i></b></div><div class="mt"><b>Morning in the mountains</b><span>Alpine Films · 1.2M views</span></div><p class="out">Move across the card, drag, or press the arrow keys.</p></div>
</div>
<script>
const vc=document.getElementById('vc'),fr=document.getElementById('fr'),pb=document.getElementById('pb'),tm=document.getElementById('tm'),N=8;let cur=0;
function set(i){cur=Math.max(0,Math.min(N-1,i));const t=cur/(N-1);fr.style.setProperty('--h',(205-t*165).toFixed(0));fr.style.setProperty('--l1',(30+t*28)+'%');fr.style.setProperty('--l2',(52+t*20)+'%');fr.style.setProperty('--sx',(10+t*80)+'%');fr.style.setProperty('--sy',(24+Math.sin(t*Math.PI)*34)+'%');pb.style.width=(t*100)+'%';tm.textContent='0:0'+cur;vc.setAttribute('aria-valuenow',cur);vc.setAttribute('aria-valuetext','Frame '+(cur+1)+' of '+N);}
function at(e){const r=vc.getBoundingClientRect();set(Math.floor((e.clientX-r.left)/r.width*N));}
vc.addEventListener('pointermove',at);vc.addEventListener('pointerdown',at);vc.addEventListener('pointerleave',()=>set(0));vc.addEventListener('keydown',e=>{if(e.key==='ArrowRight'){e.preventDefault();set(cur+1);}else if(e.key==='ArrowLeft'){e.preventDefault();set(cur-1);}else if(e.key==='Home')set(0);else if(e.key==='End')set(N-1);});set(0);
</script>
</body></html>