Skip to content

Instantly share code, notes, and snippets.

View joelmichael's full-sized avatar

Joel Hayhurst joelmichael

  • Morro Bay, California
View GitHub Profile
document.addEventListener('DOMContentLoaded', function(event) {
var changeColorScheme = function() {
var html = document.querySelector('html');
if (this.matches)
html.classList.add('dark');
else
html.classList.remove('dark');
}
@joelmichael
joelmichael / dark.js
Created September 3, 2021 01:27
Auto dark mode detection
document.addEventListener('DOMContentLoaded', function(event) {
var changeColorScheme = function() {
var html = document.querySelector('html');
if (this.matches)
html.classList.add('dark');
else
html.classList.remove('dark');
}