---
title: "Automatic Dark Mode With JavaScript"
url: https://daily.dev/posts/automatic-dark-mode-with-javascript-qcjioaz8b
source_url: https://medium.com/pragmatic-programmers/automatic-dark-mode-with-javascript-8b8b717699ca?source=rss------javascript-5
type: article
source: "Medium"
published: 2022-04-14T11:09:13.710Z
updated: 2022-04-14T11:09:13.711Z
tags: ["javascript"]
reading_time: 1
upvotes: 135
comments: 4
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Automatic Dark Mode With JavaScript

**[Medium](https://daily.dev/sources/medium_js)** · 1 min read · 135 upvotes · 4 comments

## Summary

Detecting Users’ OS Dark Mode Preference Using matchMedia() using JavaScript. For many users, dark mode provides a more eye-friendly interface with fewer white tones that can cause eyestrain. In JavaScript, you can takes advantage of the Window interface’s match media() method to check the value of the prefers-color-scheme CSS feature.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://medium.com/pragmatic-programmers/automatic-dark-mode-with-javascript-8b8b717699ca?source=rss------javascript-5>

## Community discussion

Top comments from developers on daily.dev.

**@redas24** · 1 upvotes

> For beginner programmer like me that`s will be really helpful thank you for good article.
> Lucas

**@maarcusvinicius** · 0 upvotes

> I love it

**@miky** · 0 upvotes

> So simple... :O

**@dansowaru** · 0 upvotes

> awesome, always good to know quick ways to reach the optimal user experience!!

## Similar posts on daily.dev

- [Don’t just attend KubeCon \+ CloudNativeCon, Merge Forward your experience\!](https://daily.dev/posts/don-t-just-attend-kubecon-cloudnativecon-merge-forward-your-experience--l0rpp73x8) · CNCF · 0 upvotes · 0 comments
- [Announcing H2 2026 KCDs](https://daily.dev/posts/announcing-h2-2026-kcds-m96goajm1) · CNCF · 1 upvotes · 0 comments
- [Two months of Open Community Groups](https://daily.dev/posts/two-months-of-open-community-groups-asf52zhbs) · CNCF · 0 upvotes · 0 comments
- [CNCF Unveils Schedule for KubeCon \+ CloudNativeCon Europe 2026](https://daily.dev/posts/cncf-unveils-schedule-for-kubecon-cloudnativecon-europe-2026-ikhcoa5cb) · CNCF · 2 upvotes · 0 comments
- [CNCF Debuts KubeCon \+ CloudNativeCon Japan 2026 Schedule](https://daily.dev/posts/cncf-debuts-kubecon-cloudnativecon-japan-2026-schedule-xp5pyudub) · CNCF · 1 upvotes · 0 comments

---

Tags: [#javascript](https://daily.dev/tags/javascript)

[View this post on daily.dev](https://daily.dev/posts/automatic-dark-mode-with-javascript-qcjioaz8b)
