Mendeteksi tema browser
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
console.log('User prefers dark mode on his device');
}
Marwen Labidi
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
console.log('User prefers dark mode on his device');
}
@media (prefers-color-scheme: dark) {
// color variables for users which want your site to be dark
}
@media (prefers-color-scheme: light) {
// color variables for users which want your site to be light
}