nvchad.github.io
nvchad.github.io copied to clipboard
Bugfix/theme initial state
Issue:
The website currently attempts to set the theme from localStorage
without checking if a value is actually stored. This can lead to undefined
being used as the theme, causing unexpected behavior e.g. having to double click the theme-toggler to get to dark mode.
Steps to Reproduce:
- Clear cookies on the official website (https://nvchad.com).
- Reload the page.
Expected Behavior:
The website should load with a valid theme applied, even if no theme preference is set in localStorage
yet.
Proposed Fix:
This pull request introduces a check for localStorage.theme
. If the value is not set (i.e., undefined
), the system's preferred theme will be used as the default and saved to localStorage
for future visits.
Manual testing has been conducted to ensure the fix works as intended.