[Home] >  Misc >  Detect dark mode

Detect dark mode

JavaScript version

const isDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;

TypeScript version

const isDarkMode: boolean = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;