Skip to content
This repository was archived by the owner on May 21, 2024. It is now read-only.
This repository was archived by the owner on May 21, 2024. It is now read-only.

Add support for system level theme preference #238

@soulcramer

Description

@soulcramer

Since the new version of iOS and Android add a System level dark theme preference.

It would be a easy small feature to do.

In my opinion we should add a "system default" option in the settings.
Then in the typescript file where the theme is applied, just check if the setting is system default, if it is then add a listener to the prefers-color-scheme media value :

const darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
darkModeMediaQuery.addListener((e) => {
  const darkModeOn = e.matches;
  console.log(`Dark mode is ${darkModeOn ? '🌒 on' : '☀️ off'}.`);
});

Availability: https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme#Browser_compatibility

You can inspire yourself from this post on web.dev https://web.dev/prefers-color-scheme

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions