feat(theme): configurable dark mode with system preference support #10669
+440
−41
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.
This PR implements a robust and configurable dark mode system with three options:
light,dark, andsystem(auto-detect).Key Changes
New
themeConfiguration:theme: { defaultMode: '...' }to Swagger UI config.'system'(Default): Automatically respects the user's OS/browser preference.'dark': Forces dark mode.'light': Forces light mode.Core Plugin Implementation:
src/core/plugins/dark-mode) for better state management.src/standalone/plugins/top-bar/components/TopBar.jsx- Pass dark mode propsdocker/configurator/variables.js- Helper for Docker env varstest/unit/standalone/plugins/top-bar/DarkModeToggle.jsx- Updated testDocker Support:
THEME_DEFAULT_MODEenvironment variable support.-e THEME_DEFAULT_MODE=dark).CSS Isolation:
.swagger-uito prevent style leakage into host applications during embedded usage.Backward Compatibility:
dark-modeclass) still work.Usage Example
Documentation
docs/usage/dark-mode.mddocs/usage/configuration.mdCloses #10663
Description
Implements configurable dark mode with
light,dark, andsystem(auto-detect) options, including Docker support viaTHEME_DEFAULT_MODEenv var.Motivation and Context
As a user, I wanted native support for system-preferred dark mode and easier configuration options to improve the overall viewing experience.
Fixes #10663
How Has This Been Tested?
Manually verified
theme.defaultModein browser (Chrome/Firefox), tested Docker environment variable injection, and verified CSS scoping prevents leakage.Screenshots (if appropriate):
Checklist
My PR contains...
src/is unmodified: changes to documentation, CI, metadata, etc.)package.json)My changes...
Documentation
Automated tests