mirror of
https://github.com/Fechin/reference.git
synced 2026-11-20 21:23:11 +03:00
384 B
384 B
title, tags, layout
| title | tags | layout | |||
|---|---|---|---|---|---|
| How to detect dark mode in JavaScript |
|
note |
In this Article we will go through how to detect dark mode only using single line of code in JavaScript.
Let's define this short function:
const isDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;