To have a dark mode is a more and more common thing. But it can be pretty tricky.
Lea Verou wrote an awesome article how you can handle this task with CSS and custom properties in a pretty nice way:
Dark mode in 5 minutes, with inverted lightness variables – Lea Verou
I already followed that guide for my latest web project.