Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

(I'm gonna abuse your example to rant about dark mode selection interfaces.)

There's a small problem with your example: Dark mode isn't a binary setting.

For modern applications, there should be 3 settings: System, Light, and Dark. (I like to use a dropdown menu to select the theme).

This makes it work for people whose theme changes automatically between day and night (it's a built-in system setting on macOS, and possibly Windows). L

For a web app, Light and Dark can set a value in localStorage which sets the theme manually, but System should remove the setting.

You can detect the correct theme when the page is loaded, and also add an event listener to detect theme changes (so that either the user or the OS can change the current theme). It's actually not too difficult to set up properly.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: