Skip to content
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

defaultTheme did't work in the latest Chrome for macOS #240

Open
jizhi0v0 opened this issue Dec 1, 2023 · 7 comments
Open

defaultTheme did't work in the latest Chrome for macOS #240

jizhi0v0 opened this issue Dec 1, 2023 · 7 comments

Comments

@jizhi0v0
Copy link

jizhi0v0 commented Dec 1, 2023

CleanShot 2023-12-01 at 18 05 19@2x

CleanShot 2023-12-01 at 18 05 56@2x

It works on Safari and ios Chrome(Version 119.0.6045.199 (Official Build) (arm64))

I don't know if I report this issue here. It has troubled me for a long time.

@jizhi0v0
Copy link
Author

jizhi0v0 commented Dec 1, 2023

when I set enableSystem to false.

CleanShot 2023-12-01 at 18 11 12@2x

@ethanleifer
Copy link

Any update on this?

@stabildev
Copy link

Same issue here

@ethanleifer
Copy link

ethanleifer commented Dec 6, 2023

Hot fix for now...

Does the trick though!

'use client'

import { ThemeProvider, useTheme } from 'next-themes'
import { useEffect } from 'react'

export function DarkThemeProvider({ children }: { children: React.ReactNode }) {
  const { setTheme, theme } = useTheme()

  useEffect(() => {
    setTheme('dark')
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [theme])

  return (
    <ThemeProvider
      attribute="class"
      defaultTheme="dark"
      disableTransitionOnChange
    >
      {children}
    </ThemeProvider>
  )
}

@barrynorman
Copy link

barrynorman commented Dec 15, 2023

@ethanleifer does not work for me 100%.
Somehow the fonts are not loaded.

I used forcedTheme for my custom theme.

Updated: I'm using the ThemeProvider in the _app.tsx.
Workaround for me is to use forcedTheme, since this is working

@ethanleifer
Copy link

Forced theme wasn't working for me either

@igor9silva
Copy link

Same here. Workaround from @ethanleifer worked.

@trm217 trm217 assigned trm217 and unassigned trm217 Apr 22, 2024
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

No branches or pull requests

6 participants