Pixelbeeld dat scherp wordt
A photo that starts as coarse blocks and sharpens in a few steps when you hover, focus or tap it; move away and it coarsens again. For a teaser of a new project or a reveal on a launch page. One SVG filter (flood, tile, composite, morphology), no canvas; with reduced motion it switches straight between sharp and coarse.
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.
<!-- Pixelbeeld dat scherp wordt · © 2026 NedDev BV · NedDev Lab-licentie (gratis gebruik, niet doorverkopen) · neddev.com/nl/lab/gebruik/#licentie -->
<div class="jouw-container">
<div class="pxs">
<svg class="pxs__defs" width="0" height="0" aria-hidden="true" focusable="false"><filter id="pxs-filter" x="0" y="0" width="100%" height="100%" color-interpolation-filters="sRGB"><feFlood x="12" y="12" width="1" height="1" result="pxs-p"/><feComposite in="pxs-p" in2="pxs-p" operator="over" width="25" height="25"/><feTile result="pxs-raster"/><feComposite in="SourceGraphic" in2="pxs-raster" operator="in"/><feMorphology operator="dilate" radius="12"/></filter></svg>
<figure class="pxs__fig" tabindex="0" aria-describedby="pxs-tip">
<img class="pxs__img" src="https://neddev.com/lab-media/site-hotel-5.webp" alt="Fietspad met bomenrij door de polder" draggable="false">
<figcaption class="pxs__cap"><strong>Nieuw: fietsroute Waterland</strong><span id="pxs-tip">Beweeg over het beeld of tik erop</span></figcaption>
</figure>
</div>
</div>/* Pixelbeeld dat scherp wordt · © 2026 NedDev BV · NedDev Lab-licentie (gratis gebruik, niet doorverkopen) · neddev.com/nl/lab/gebruik/#licentie */
.pxs{position:absolute;inset:0;container-type:size;display:flex;align-items:center;justify-content:center;padding:14px;background:#f4f3f1;font-family:'Switzer',system-ui,sans-serif;color:#0a0a0a}
.pxs__defs{position:absolute;width:0;height:0;overflow:hidden}
.pxs__fig{margin:0;width:min(300px,100%,calc((100cqh - 64px) * 1.6));display:flex;flex-direction:column;gap:8px;cursor:pointer;outline:none}
.pxs__img{display:block;width:100%;aspect-ratio:16/10;object-fit:cover;border-radius:4px;filter:url(#pxs-filter);background:#d9d5ce}
.pxs__fig.is-scherp .pxs__img{filter:none}
.pxs__fig:focus-visible .pxs__img{outline:2px solid #F5480F;outline-offset:3px}
.pxs__cap{display:flex;justify-content:space-between;align-items:baseline;gap:10px;flex-wrap:wrap}
.pxs__cap strong{font-size:14px;font-weight:600}
.pxs__cap span{font-size:12px;color:#6b6862}// Pixelbeeld dat scherp wordt · © 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('.pxs'); if (!box) return;
const fig = box.querySelector('.pxs__fig');
const flood = box.querySelector('feFlood'), comp = box.querySelector('feComposite'), morf = box.querySelector('feMorphology');
const rm = matchMedia('(prefers-reduced-motion: reduce)').matches;
const STAP = [25, 19, 15, 11, 9, 7, 5, 3, 1];
let i = 0, doel = 0, t = 0;
const toon = () => {
const s = STAP[i], h = (s - 1) / 2;
fig.classList.toggle('is-scherp', s === 1);
if (s === 1) return;
flood.setAttribute('x', h); flood.setAttribute('y', h);
comp.setAttribute('width', s); comp.setAttribute('height', s);
morf.setAttribute('radius', h);
};
const loop = () => {
clearTimeout(t);
if (i === doel) return;
i += doel > i ? 1 : -1; toon();
t = setTimeout(loop, 55);
};
const naar = d => { doel = d; if (rm) { i = d; toon(); } else loop(); };
const scherp = () => naar(STAP.length - 1), grof = () => naar(0);
fig.addEventListener('pointerenter', e => { if (e.pointerType === 'mouse') scherp(); });
fig.addEventListener('pointerleave', e => { if (e.pointerType === 'mouse' && document.activeElement !== fig) grof(); });
fig.addEventListener('focus', () => { if (fig.matches(':focus-visible')) scherp(); }); fig.addEventListener('blur', grof);
fig.addEventListener('click', e => { if (e.pointerType !== 'mouse') (doel === 0 ? scherp : grof)(); });
fig.addEventListener('keydown', e => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); (doel === 0 ? scherp : grof)(); } });
toon();
}
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 →