Skip to content

fix: use resolvedTheme for accurate theme management #105

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

Merged
merged 1 commit into from
Mar 8, 2025

Conversation

alvinsjoy
Copy link
Contributor

Currently, when enableSystem is set,

scira/app/providers.tsx

Lines 19 to 24 in 83d73d7

<ThemeProvider
attribute="class"
defaultTheme="system"
enableSystem
disableTransitionOnChange
>

the theme parameter returns system instead of light or dark. This causes an issue where new users (those without a saved theme preference in localStorage) cannot change the theme on their first click. To reproduce the issue, clear cookies and try toggling the theme.

theme.mp4

As stated in the next-themes docs,
when enableSystem is true and the active theme is system, theme remains system while resolvedTheme returns whether the system preference is resolved to dark or light.

The new implementation is similar to the one done by shadcn:
https://github.com/shadcn-ui/ui/blob/12d4cf2ab0caefec5d6232e6c32220a8e62d73c4/apps/v4/components/mode-toggle.tsx#L10

Copy link

vercel bot commented Mar 8, 2025

@alvinsjoy is attempting to deploy a commit to the Zaid Mukaddam's Team Team on Vercel.

A member of the Team first needs to authorize it.

@zaidmukaddam zaidmukaddam merged commit 01f7369 into zaidmukaddam:main Mar 8, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants