Profile picture of Michael GroßklausMichael Großklaus

RSS
Color scheme

Collecting some frontend related notes, thoughts, bookmarks and tips.

  1. Implementing a light and dark theme based on the user's OS settings has become quite popular. But often users just want their OS to be dark, while they prefer reading a website with a light background, for example. It is therefore considered good practice to offer a theme toggle, that allows the user to change the theme of the website regardless of their OS theme. […]

  2. There is a change event that can be used to listen to media query changes:

    const mediaQuery = window.matchMedia("…");
    
    mediaQuery.addEventListener("change", (e) => {});