feat: Implement dynamic theme switching and dark mode support#3323
feat: Implement dynamic theme switching and dark mode support#3323DSingh0304 wants to merge 24 commits intoapache:masterfrom
Conversation
|
Hi @Baoyuantop, I have implemented the dark mode support for the Dashboard as discussed in the community. The PR is ready for your review whenever you have a moment. I would appreciate any feedback you have. |
There was a problem hiding this comment.
Pull request overview
Adds end-to-end dark mode support across the dashboard UI by enabling Mantine color-scheme persistence, providing a header toggle, and aligning third-party UI theming (AntD + Monaco) with the active scheme.
Changes:
- Enable automatic (OS-driven) color scheme by default in
MantineProviderand bootstrap scheme early inindex.html. - Add a header theme segmented control with a short transition window for smoother switching.
- Propagate scheme changes to Ant Design (theme algorithms) and Monaco editor (vs-light/vs-dark), plus add Playwright coverage.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/styles/global.css | Adds a global transition rule during theme switching. |
| src/main.tsx | Sets Mantine default color scheme to auto. |
| src/config/antdConfigProvider.tsx | Switches AntD theme algorithm based on computed color scheme. |
| src/components/Header/ThemeToggle.tsx | New theme toggle control with transition handling. |
| src/components/Header/index.tsx | Places the new theme toggle into the header actions. |
| src/components/form/Editor.tsx | Makes Monaco theme follow the computed color scheme (incl. imperative update). |
| index.html | Adds an early script to set data-mantine-color-scheme before React mounts. |
| e2e/tests/dark-mode.spec.ts | Adds Playwright tests for theme switching and persistence. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
a7ccf74 to
0c5402c
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Hi @Baoyuantop I have addressed all the comments of copilot and made the changes. Can you please review this feature whenever you get time. Thank You!! |
Why submit this pull request?
What changes will this PR take into?
Add dark mode theme support to the APISIX Dashboard, allowing users to switch between light, dark, and system preferred color schemes via a segmented control (☀️ Light / 🌙 Dark / 🖥️ Auto) in the header.
Changes
<script>inindex.htmlthat reads the persisted color scheme fromlocalStorageand setsdata-mantine-color-schemeon<html>before CSS parses prevents a flash of the wrong theme on page loaddefaultColorScheme="auto"onMantineProviderso the dashboard respects the user's OS preference by defaultuseComputedColorScheme('light')to resolve the actual scheme (since Ant Design does not handle'auto'internally), then conditionally appliedtheme.darkAlgorithmonConfigProviderkeepsProTablein sync with the Mantine shellmonaco.editor.setTheme()viauseEffect+onMountref, since Monaco does not re-theme on React prop changes after initial mountThemeTogglesegmented control component in the header with three options: Light / Dark / Autobodyduring theme switches (removed after 200ms to avoid impacting Lighthouse performance)emulateMedia), theme persistence across page reloads, and cycling through all theme modesTechnical notes
localStorage(mantine-color-scheme-value)forceColorSchemewas intentionally avoided it overrides system preference and would make auto mode a silent no opglobal.cssalready uses Mantine CSS variables (--mantine-color-*), which auto-adapt no manual overrides were neededRelated issues
resolve #3322
Screenshot

Checklist: