Dark Mode Web Design — How to Do It Right
Table of Contents
Dark Mode Web Design — How to Do It Right
Why Dark Mode Matters
Dark mode isn’t just a trend anymore. For many users, it’s a genuine usability and accessibility feature. People who work late at night, spend long hours staring at screens, or have light sensitivity often prefer darker interfaces because they’re easier on the eyes.
But here’s the problem: a lot of websites implement dark mode poorly.
You’ve probably seen it before:
- Pure black backgrounds
- Low-contrast text
- Colors that look oversaturated
- UI elements that feel lifeless or hard to read
A bad dark mode can actually reduce readability instead of improving it. So if you’re going to add dark mode to your website, it’s worth doing properly.
Mistake 1: Using Pure Black
The most common mistake is using #000000 as the background color.
Pure black creates extremely harsh contrast against white text, making reading uncomfortable over time. It also removes visual depth from the interface and can make everything feel flat.
Instead, use very dark shades of gray or navy tones.
/* Bad */
background: #000000;
/* Better */
background: #0f172a;
/* Other good options */
background: #030712;
background: #111827;
If you’re using Tailwind CSS, colors like gray-900 and gray-950 are excellent starting points.
These softer dark tones create a cleaner and more premium-looking interface while remaining comfortable for long reading sessions.
Mistake 2: Inverting Colors Blindly
Another major issue is simply inverting every color for dark mode.
That usually causes:
- Images to look strange
- Accent colors to become overly aggressive
- UI components to lose visual balance
Dark mode should feel intentionally designed — not automatically flipped.
Instead of blindly inverting colors:
- Adjust accent colors individually
- Reduce saturation slightly
- Test readability carefully
- Make sure hover states and shadows still feel natural
Good dark mode design is about balance, not inversion.
Mistake 3: Ignoring System Preferences
Modern operating systems already allow users to choose their preferred color scheme.
Your website should respect that preference automatically.
You can do this using prefers-color-scheme:
@media (prefers-color-scheme: dark) {
:root {
--background: #0f172a;
--text: #f1f5f9;
}
}
This ensures users immediately get the experience they expect without needing to manually toggle anything.
After that, you can still provide a custom theme switcher so users can override the default behavior.
Getting It Right with Tailwind CSS
Tailwind makes dark mode surprisingly simple.
Using the dark: modifier, you can style elements for both light and dark themes without writing custom CSS everywhere.
<div class="bg-white dark:bg-gray-950 text-gray-900 dark:text-gray-100">
Content that adapts automatically
</div>
Combined with:
darkMode: "class"
inside your Tailwind config, you get full control over when dark mode is applied.
This approach is clean, scalable, and easy to maintain.
Storing the User’s Preference
If users manually switch themes, always remember their preference.
The easiest way is using localStorage:
const toggle = () => {
document.documentElement.classList.toggle("dark");
localStorage.setItem(
"theme",
document.documentElement.classList.contains("dark")
? "dark"
: "light"
);
};
Then when the page loads, you can restore the saved preference automatically.
This small detail greatly improves user experience.
Extra Tips for Better Dark Mode Design
Here are a few additional improvements many developers overlook.
Use Softer Whites
Avoid pure white text (#ffffff) on dark backgrounds.
Instead, use softer shades like:
#f1f5f9#e5e7eb#d1d5db
This reduces eye strain significantly.
Keep Shadows Subtle
Heavy shadows often look unnatural in dark mode.
Instead:
- Reduce opacity
- Use softer blur values
- Rely more on borders and contrast
Dark interfaces already create visual depth naturally.
Test Real Content
A dark mode can look beautiful with placeholder content but fail with real-world usage.
Always test:
- Long paragraphs
- Images
- Code blocks
- Tables
- Forms
- Buttons
- Navigation menus
Real content reveals real problems.
Final Thoughts
A well-designed dark mode isn’t just about aesthetics — it’s about comfort, accessibility, and attention to detail.
When done correctly, dark mode can make your website feel modern, polished, and far more enjoyable to use.
Take the time to design it intentionally instead of treating it like an afterthought.
Your users — especially the late-night ones — will notice the difference.