---
title: "Discussion on \"The easiest way to build a Dark Mode\" | Hashnode"
description: "Discussion on \"The easiest way to build a Dark Mode\". Most operating systems natively support dark mode now. I have become so used to it that anything without a dark theme becomes painful in the evening.\nAs I gave my website a minor visual refresh this week, I often coded into the evening. When everythi..."
url: "https://hashnode.com/posts/the-easiest-way-to-build-a-dark-mode/5fd9fc744d058528f6ceee04"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [The easiest way to build a Dark Mode](https://domhabersack.hashnode.dev/the-easiest-way-to-build-a-dark-mode?utm_source=hashnode&utm_medium=feed)

Most operating systems natively support dark mode now. I have become so used to it that anything without a dark theme becomes painful in the evening. As I gave my website a minor visual refresh this week, I often coded into the evening. When everythi...

Dec 16, 2020 · 4 min read · domhabersack.hashnode.dev  
Read the article

-   [#css](https://hashnode.com/tag/css)
-   [#design](https://hashnode.com/tag/design)
-   [#accessibility](https://hashnode.com/tag/accessibility)
-   [#a11y](https://hashnode.com/tag/a11y)
-   [#media-queries](https://hashnode.com/tag/media-queries)

## Written by

[Dom Habersack](https://hashnode.com/@domhabersack)

@domhabersack

  
[View profile](https://hashnode.com/@domhabersack)

Teaching everything I know.

## Responses 1

Markdown supported · ⌘↵ to post

[Etiene James](https://hashnode.com/@St80ene)

[Dec 16, 2020](https://hashnode.com/posts/the-easiest-way-to-build-a-dark-mode/5fd9fc744d058528f6ceee04/comment/5fda54ea33db062ae10cddf6)

Nice article. But I was like, "How do a User switch between both modes?". I'll be super grateful to get an answer to that.

[Dom Habersack](https://hashnode.com/@domhabersack)

[Dec 16, 2020](https://hashnode.com/posts/the-easiest-way-to-build-a-dark-mode/5fd9fc744d058528f6ceee04/comment/5fda54ea33db062ae10cddf6#reply-5fda629dd296552b06489949)

With this approach, there is no active switch. If the operating system supports Dark Mode, the CSS respects that global setting.

Like when I go into my iPhone’s settings and switch EVERYTHING to Dark Mode (Settings.app → Display & Brightness → Appearance). macOS has a similar setting. I don’t know where to find it on Android, Windows, or Linux.

If we wanted an active toggle a visitor can use, we’d have to use JavaScript instead of (or possibly in addition to) this media query.

You can see a demo of this by switching your phone from light to dark mode on twitter.com, they seem to use this method. I added it to my site just last week: islovely.co/posts

[Etiene James](https://hashnode.com/@St80ene)

[Dec 17, 2020](https://hashnode.com/posts/the-easiest-way-to-build-a-dark-mode/5fd9fc744d058528f6ceee04/comment/5fda54ea33db062ae10cddf6#reply-5fdbea0d1485f22e24b329e5)

Thanks for taking out time to answer. I have learned a lot.
