Skip to content

feat: Added support for automatic dark/light mode based on user os settings #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rahulptl165
Copy link

@rahulptl165 rahulptl165 commented Mar 7, 2025

Resolves #56 .

Checklist

Please ensure the following tasks are completed before submitting this pull request.

  • Read and understand the Code of Conduct.
  • Read and understood the licensing terms.
  • Searched for existing issues and pull requests before submitting this pull request.
  • Filed an issue (or an issue already existed) prior to submitting this pull request.
  • Rebased onto latest master.
  • Submitted against master branch.

Description

This PR adds a new "Auto" theme option that automatically switches between dark and light modes based on the user’s operating system preferences (using prefers-color-scheme).

changes i've made:

  • Updated the THEMES array to include an "Auto" option alongside "Light" and "Dark".
  • Modified _onThemeChange to detect OS theme preferences via window.matchMedia('(prefers-color-scheme: dark)') when "Auto" is selected, then apply the appropriate theme (dark or light).

Related Issues

This pull request:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

Recording new feature

Screen.Recording.2025-03-08.162444.mp4

No.


@stdlib-js/reviewers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support automatic light/dark mode theme based on OS
1 participant