Repository navigation
feat(theme): add persistent dark mode toggle - #845
Merged
dzekojohn4 merged 1 commit intoOct 20, 2026
Merged
dzekojohn4 merged 1 commit into
dzekojohn4 merged 1 commit into
Conversation
|
@lovesmilesmall-hue Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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
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.
Summary
Adds a light/dark theme toggle to the frontend with a persistent user preference. Users can switch themes from the navbar, the choice is remembered across reloads, and first-time visitors get the theme matching their system preference.
Problem
Tailwind was configured for class-based dark mode (
darkMode: ["class"]), but nothing ever added thedarkclass to the document, so the dark styles were unreachable. There was no control to switch themes, no persistence of a user's choice, and no handling of the system preference, meaning the app always rendered in light mode regardless of the environment.Changes Made
frontend/hooks/useTheme.js: resolves the active theme from the persistedlocalStoragevalue, falling back toprefers-color-scheme, applies thedark/lightclass todocument.documentElement, and persists an explicit toggle choice understellarhunts.theme.frontend/components/ThemeToggle.jsx: a button that switches between themes and shows a sun or moon icon for the current theme.frontend/components/Navbar.jsxnext to the mobile menu control.frontend/app/layout.jsthat applies the stored or system theme before hydration to avoid a light-mode flash on load.Implementation Details
useThemetoggles thedark/lightclasses on the root element, matching the existing Tailwind class strategy so all components usingdark:variants are themed consistently. The initial class is set by a small inline script in the document head, which readslocalStoragefirst and otherwise consultsmatchMedia("(prefers-color-scheme: dark)"); React state then syncs to that value on mount so the toggle reflects reality without a flash.Closes #692
Closes #694
Closes #695
Closes #706