Theme Toggle Reveal
Schakelaar voor licht en donker waarbij het nieuwe thema als cirkel vanuit de knop over het blok groeit. Werkt met een tijdelijke kopie en clip-path, dus in elke browser en alleen binnen het eigen blok.
Bureau Kade
Huizen die met hun bewoners meegroeien.
Architecten in Leiden voor verbouw, nieuwbouw en herbestemming.
Zo gebruik je het
- Plak de HTML op de plek waar het onderdeel moet komen.
- Zet de CSS in je stylesheet. Alle klassen hebben een eigen voorvoegsel, dus niets botst met je eigen opmaak.
- Voeg de JavaScript toe en roep init() aan met het element waar de HTML in staat.
<!-- Theme Toggle Reveal · © 2026 NedDev BV · NedDev Lab-licentie (gratis gebruik, niet doorverkopen) · neddev.com/nl/lab/gebruik/#licentie -->
<div class="jouw-container">
<div class="ttr">
<div class="ttr__vlak" data-thema="licht">
<div class="ttr__balk">
<span class="ttr__merk">Bureau Kade</span>
<button class="ttr__knop" type="button" aria-pressed="false" aria-label="Donker thema">
<svg class="ttr__ico ttr__ico--zon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="4.2"/><path d="M12 2.5v2.2M12 19.3v2.2M2.5 12h2.2M19.3 12h2.2M5.3 5.3l1.6 1.6M17.1 17.1l1.6 1.6M5.3 18.7l1.6-1.6M17.1 6.9l1.6-1.6"/></svg>
<svg class="ttr__ico ttr__ico--maan" viewBox="0 0 24 24" aria-hidden="true"><path d="M19.5 14.6A8 8 0 0 1 9.4 4.5a8 8 0 1 0 10.1 10.1z"/></svg>
</button>
</div>
<div class="ttr__body">
<h3 class="ttr__kop">Huizen die met hun bewoners meegroeien.</h3>
<p class="ttr__tekst">Architecten in Leiden voor verbouw, nieuwbouw en herbestemming.</p>
</div>
</div>
</div>
</div>/* Theme Toggle Reveal · © 2026 NedDev BV · NedDev Lab-licentie (gratis gebruik, niet doorverkopen) · neddev.com/nl/lab/gebruik/#licentie */
.ttr{position:relative;width:100%;height:100%;padding:10px;box-sizing:border-box;font-family:'Switzer',sans-serif;container-type:inline-size}
.ttr__vlak{--ttr-bg:#ffffff;--ttr-tekst:#0a0a0a;--ttr-zacht:#615d59;--ttr-lijn:#d9d5cf;position:relative;height:100%;box-sizing:border-box;display:flex;flex-direction:column;justify-content:space-between;gap:12px;padding:clamp(14px,3.6cqw,32px);background:var(--ttr-bg);color:var(--ttr-tekst);border:1px solid var(--ttr-lijn);border-radius:4px;overflow:hidden}
.ttr__vlak[data-thema="donker"]{--ttr-bg:#0a0a0a;--ttr-tekst:#f4f3f1;--ttr-zacht:#a8a39d;--ttr-lijn:#2a2826}
.ttr__balk{display:flex;align-items:center;justify-content:space-between;gap:12px}
.ttr__merk{font-size:15px;font-weight:600}
.ttr__knop{display:grid;place-items:center;width:38px;height:38px;padding:0;border:1px solid var(--ttr-lijn);border-radius:4px;background:transparent;color:var(--ttr-tekst);cursor:pointer;transition:border-color .15s ease,color .15s ease}
.ttr__knop:hover{border-color:#F5480F;color:#F5480F}
.ttr__knop:focus-visible{outline:2px solid #F5480F;outline-offset:2px}
.ttr__ico{grid-area:1/1;width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.ttr__ico--maan{display:none}
.ttr__vlak[data-thema="donker"] .ttr__ico--zon{display:none}
.ttr__vlak[data-thema="donker"] .ttr__ico--maan{display:block}
.ttr__kop{margin:0;font-size:clamp(20px,6.6cqw,72px);font-weight:700;line-height:1;letter-spacing:-.02em;max-width:16ch}
.ttr__tekst{margin:.7em 0 0;font-size:clamp(13px,2cqw,16px);line-height:1.45;color:var(--ttr-zacht);max-width:52ch}
.ttr__kopie{position:absolute;inset:10px;height:auto;pointer-events:none;z-index:2}// Theme Toggle Reveal · © 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){
var w = root.querySelector('.ttr'); if (!w) return;
var vlak = w.querySelector('.ttr__vlak'), knop = w.querySelector('.ttr__knop');
var rustig = window.matchMedia && matchMedia('(prefers-reduced-motion: reduce)').matches;
var bezig = false;
function zet(el, thema){ el.setAttribute('data-thema', thema); }
function status(thema){ var donker = thema === 'donker'; knop.setAttribute('aria-pressed', donker ? 'true' : 'false'); knop.setAttribute('aria-label', donker ? 'Licht thema' : 'Donker thema'); }
knop.addEventListener('click', function(){
if (bezig) return;
var nieuw = vlak.getAttribute('data-thema') === 'donker' ? 'licht' : 'donker';
status(nieuw);
if (rustig || !Element.prototype.animate){ zet(vlak, nieuw); return; }
bezig = true;
var kopie = vlak.cloneNode(true);
kopie.classList.add('ttr__kopie'); kopie.setAttribute('aria-hidden', 'true'); kopie.setAttribute('inert', '');
zet(kopie, nieuw);
w.appendChild(kopie);
var kb = knop.getBoundingClientRect(), vb = vlak.getBoundingClientRect();
var x = kb.left + kb.width / 2 - vb.left, y = kb.top + kb.height / 2 - vb.top;
var r = Math.hypot(Math.max(x, vb.width - x), Math.max(y, vb.height - y)) + 4;
var a = kopie.animate([
{ clipPath: 'circle(0px at ' + x + 'px ' + y + 'px)' },
{ clipPath: 'circle(' + r + 'px at ' + x + 'px ' + y + 'px)' }
], { duration: 650, easing: 'cubic-bezier(.6,0,.25,1)', fill: 'forwards' });
a.onfinish = function(){ zet(vlak, nieuw); kopie.remove(); bezig = false; };
});
}
init(document.querySelector('.jouw-container'));
Meer uit componenten
Iets gezien dat je mooi vindt?
Zet het in je selectie en stuur hem op. Dan bouwen we je site eromheen, in jouw huisstijl.
Neem contact op →