parent
5a728445b5
commit
45e143f784
@ -0,0 +1,19 @@
|
|||||||
|
function detectTheme() {
|
||||||
|
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
||||||
|
// Dark mode
|
||||||
|
console.log("Dark mode detected");
|
||||||
|
// Add your dark mode styles or trigger a CSS class change here
|
||||||
|
document.body.classList.add('dark-mode');
|
||||||
|
} else {
|
||||||
|
// Light mode
|
||||||
|
console.log("Light mode detected");
|
||||||
|
// Add your light mode styles or trigger a CSS class change here
|
||||||
|
document.body.classList.add('light-mode');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call the function to detect the initial theme
|
||||||
|
detectTheme();
|
||||||
|
|
||||||
|
// Listen for changes in the system preference
|
||||||
|
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', detectTheme);
|
Loading…
Reference in New Issue