Brandur wrote a really nice tutorial on how to implement a dark mode, that uses prefers-reduced-motion and some local storage, plus some JavaScript to make a tri-state toggle to keep user preferences between always light, always dark, and follow device theme. Here you go: https://brandur.org/fragments/dark-mode-notes
Love it, especially since some of you asked for one, when I wrote Dark mode & accessibility myth (https://stephaniewalter.design/blog/dark-mode-accessibility-myth-debunked/) and explained it’s good practice to let user chose between dark and light mode.