Light vs Dark Mode Compare
The same card in light and dark, split by a draggable wipe, with a naive-invert version to show what goes wrong.
AI prompt
Clean side-by-side UI comparison of the same profile card in light and dark modes split by a vertical divider, the left half a white card with a landscape photo, dark text, blue button, the right half a designed dark theme with charcoal background, off-white text, slightly lighter blue button and the unchanged photo, a small label under each half Light and Dark designed; flat modern style. Negative: pure black, inverted photo, heavy glow, text errors. Reduced motion: static design.About this pattern
Definition
A good dark theme is designed, not inverted. Simply inverting colours turns photos into negatives, makes shadows glow, and leaves pure white or pure black that is harsh to read. A designed theme lowers surfaces to dark greys, softens text to off-white and lifts accent colours a little.
When to use it
- Use dark grey surfaces, not pure black; raise elevated surfaces slightly lighter.
- Use off-white text with enough contrast and desaturate large coloured areas.
- Keep images as they are; do not invert them.
- Shadows become less visible, so use lighter surface steps to show depth.
What the controls do
- Two build buttons and a wipe slider to move the split.
Motion & timing
- The split follows the slider.
- Reduced motion: no animation is involved.
Tips & variations
- Test both themes against the contrast ratios, especially for secondary text.
- Respect the system setting with prefers-color-scheme and allow an override.
Code of this live preview
<div class="bx"><div class="pre" id="pre" role="group" aria-label="Dark build"><button data-p="0" aria-pressed="true">Designed dark</button><button data-p="1" aria-pressed="false">Naive invert</button></div><div class="cp" id="cp"><div class="pn lt"><div class="cd"><i class="ph"></i><b>Mountain trip</b><span>3 days · 12 photos</span><u>Open</u></div></div><div class="pn dk" id="dk"><div class="cd"><i class="ph"></i><b>Mountain trip</b><span>3 days · 12 photos</span><u>Open</u></div></div><i class="dv" id="dv"></i></div><label class="rw">Wipe <b id="wv">50%</b><input id="ws" type="range" min="0" max="100" value="50"></label><p class="out" id="out"></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}
.cp{position:relative;height:150px;border-radius:12px;overflow:hidden;border:1px solid var(--line)}.pn{position:absolute;inset:0;display:grid;place-items:center}.lt{background:#f4f4f2}.dk{background:#1b1c20;clip-path:inset(0 0 0 var(--w,50%))}.cd{width:170px;border-radius:12px;padding:10px;display:grid;gap:4px;font-size:12px;background:#fff;color:#1a1a1a;box-shadow:0 4px 14px rgba(0,0,0,.14)}.ph{display:block;height:48px;border-radius:8px;background:linear-gradient(#7fb4e8,#cfe6f6 55%,#4f8a56 56%,#2f5f3a)}.cd u{text-decoration:none;justify-self:start;margin-top:2px;padding:4px 12px;border-radius:99px;background:#2f6bff;color:#fff;font-weight:700}.cd span{color:#666}.dk .cd{background:#26282e;color:#ececec;box-shadow:0 1px 0 rgba(255,255,255,.06)}.dk .cd span{color:#a4a7b0}.dk .cd u{background:#5b8cff;color:#0b1020}.dk.nv{background:#000;filter:invert(1)}.dk.nv .cd{background:#fff;color:#000;box-shadow:0 4px 14px rgba(0,0,0,.4)}.dk.nv .cd span{color:#666}.dk.nv .cd u{background:#2f6bff;color:#fff}.dv{position:absolute;top:0;bottom:0;left:var(--w,50%);width:2px;background:#2f6bff;margin-left:-1px;pointer-events:none}.out{font-size:12px;color:var(--muted)}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}const cp=document.getElementById('cp'),dk=document.getElementById('dk'),ws=document.getElementById('ws'),bs=[...document.querySelectorAll('#pre button')];let p=0;
function up(){cp.style.setProperty('--w',ws.value+'%');document.getElementById('wv').textContent=ws.value+'%';dk.classList.toggle('nv',p===1);document.getElementById('out').textContent=p===0?'Designed: dark grey surface, off-white text, softer accent, photo unchanged.':'Naive invert: the photo becomes a negative, the card flips to white, the contrast is harsh.';bs.forEach(b=>b.setAttribute('aria-pressed',String(+b.dataset.p===p)));}
bs.forEach(b=>b.addEventListener('click',()=>{p=+b.dataset.p;up();}));ws.addEventListener('input',up);up();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>Light vs Dark Mode Compare — 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}
.cp{position:relative;height:150px;border-radius:12px;overflow:hidden;border:1px solid var(--line)}.pn{position:absolute;inset:0;display:grid;place-items:center}.lt{background:#f4f4f2}.dk{background:#1b1c20;clip-path:inset(0 0 0 var(--w,50%))}.cd{width:170px;border-radius:12px;padding:10px;display:grid;gap:4px;font-size:12px;background:#fff;color:#1a1a1a;box-shadow:0 4px 14px rgba(0,0,0,.14)}.ph{display:block;height:48px;border-radius:8px;background:linear-gradient(#7fb4e8,#cfe6f6 55%,#4f8a56 56%,#2f5f3a)}.cd u{text-decoration:none;justify-self:start;margin-top:2px;padding:4px 12px;border-radius:99px;background:#2f6bff;color:#fff;font-weight:700}.cd span{color:#666}.dk .cd{background:#26282e;color:#ececec;box-shadow:0 1px 0 rgba(255,255,255,.06)}.dk .cd span{color:#a4a7b0}.dk .cd u{background:#5b8cff;color:#0b1020}.dk.nv{background:#000;filter:invert(1)}.dk.nv .cd{background:#fff;color:#000;box-shadow:0 4px 14px rgba(0,0,0,.4)}.dk.nv .cd span{color:#666}.dk.nv .cd u{background:#2f6bff;color:#fff}.dv{position:absolute;top:0;bottom:0;left:var(--w,50%);width:2px;background:#2f6bff;margin-left:-1px;pointer-events:none}.out{font-size:12px;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="pre" id="pre" role="group" aria-label="Dark build"><button data-p="0" aria-pressed="true">Designed dark</button><button data-p="1" aria-pressed="false">Naive invert</button></div><div class="cp" id="cp"><div class="pn lt"><div class="cd"><i class="ph"></i><b>Mountain trip</b><span>3 days · 12 photos</span><u>Open</u></div></div><div class="pn dk" id="dk"><div class="cd"><i class="ph"></i><b>Mountain trip</b><span>3 days · 12 photos</span><u>Open</u></div></div><i class="dv" id="dv"></i></div><label class="rw">Wipe <b id="wv">50%</b><input id="ws" type="range" min="0" max="100" value="50"></label><p class="out" id="out"></p></div>
</div>
<script>
const cp=document.getElementById('cp'),dk=document.getElementById('dk'),ws=document.getElementById('ws'),bs=[...document.querySelectorAll('#pre button')];let p=0;
function up(){cp.style.setProperty('--w',ws.value+'%');document.getElementById('wv').textContent=ws.value+'%';dk.classList.toggle('nv',p===1);document.getElementById('out').textContent=p===0?'Designed: dark grey surface, off-white text, softer accent, photo unchanged.':'Naive invert: the photo becomes a negative, the card flips to white, the contrast is harsh.';bs.forEach(b=>b.setAttribute('aria-pressed',String(+b.dataset.p===p)));}
bs.forEach(b=>b.addEventListener('click',()=>{p=+b.dataset.p;up();}));ws.addEventListener('input',up);up();
</script>
</body></html>