-
Notifications
You must be signed in to change notification settings - Fork 49
feat: enhance theme detection with auto mode and multiple strategies #235
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
asgardeo-github-bot
commented
Nov 6, 2025
⚠️ No Changeset found
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go.If these changes should result in a version bump, you need to add a changeset.
Refer Release Documentation to learn how to add a changeset.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
Purpose
This pull request introduces a major refactor and enhancement to the theme detection and switching logic across the JavaScript, Browser, and React packages. It unifies and extends theme detection strategies, replacing the old
'class'mode with a more flexible'auto'mode that supports detection via data attributes, CSS classes, and system preferences, with configurable strategy and priority. The ReactThemeProviderand related APIs are updated to leverage these new capabilities, providing more robust and customizable theme handling.Theme detection and configuration enhancements:
ThemeDetectionStrategytype and expanded theThemeDetectioninterface to support detection via data attributes, CSS classes, and system preferences, with configurable strategy and priority ('auto'mode now replaces'class'mode). [1] [2]createDataAttributeObserverandcreateAutoObserverfor robust theme change detection based on the configured strategy and priority. [1] [2]detectThemeModeto support the new strategies and fallback logic, and deprecated the'class'mode in favor of'auto'. [1] [2]ThemeDetectionStrategyandBrowserThemeDetection. [1] [2]React ThemeProvider and context updates:
ThemeProviderto use the new'auto'mode by default, support the new detection strategies, and clean up observers properly. The old'class'and'branding'modes are removed or replaced. [1] [2] [3] [4]ThemeContextand related types to use the newThemeModeand detection logic.API and type improvements:
createThemeAPI to exclude runtime detection properties from its config, clarifying its intended use.Code quality and consistency:
DOMTokenList, explicit type annotations, and improved observer setup/cleanup). [1] [2]These changes collectively provide a more flexible, reliable, and extensible foundation for theme management in applications using these packages.
Related Issues
Related PRs
Checklist
Security checks