Skip to content

Instantly share code, notes, and snippets.

@himalay
Created September 23, 2020 15:23
Show Gist options
  • Save himalay/f8eebba074cb717368e2177458dbe3dd to your computer and use it in GitHub Desktop.
Save himalay/f8eebba074cb717368e2177458dbe3dd to your computer and use it in GitHub Desktop.
Dark theme

https://dev.to/dip15739/dark-mode-with-only-1-css-property-17fl

html[theme='dark-mode'] {
    filter: invert(1) hue-rotate(180deg);
}
html[theme='dark-mode'] img,
picture,
video{
    filter: invert(1) hue-rotate(180deg);
}
.invert { filter: invert(1) hue-rotate(180deg); }

or

function comeToTheDarkside() {
  document.documentElement.style.filter = 'invert(1) hue-rotate(180deg)';
  document.body.querySelectorAll('img, picture, video')
  .forEach(el => el.style.filter = 'invert(1) hue-rotate(180deg)');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment