-
I'm trying to use Mantine with Nextra and am trying to get dark mode to sync between the 2. I try to get the theme using useTheme from the next-themes package, but it's not working in _app.js. I can access it in the component directly but now have to render the MantineProvider for each component. |
Beta Was this translation helpful? Give feedback.
Answered by
promer94
Jun 22, 2022
Replies: 1 comment 8 replies
-
First you need to install the latest version of next-themes and nextra "dependencies": {
"next-themes": "0.2.0-beta.2",
"nextra-theme-docs": "2.0.0-alpha.54",
"nextra": "2.0.0-alpha.54"
....
} Then you should ba able to access the theme in _app.js import 'nextra-theme-docs/style.css'
import { useTheme } from 'next-themes'
import React from 'react'
const TestTheme = ({ children }) => {
const { theme, setTheme, systemTheme } = useTheme()
console.log('theme', theme, systemTheme)
return children
}
export default function MyApp({ Component, pageProps }) {
// Use the layout defined at the page level, if available
const getLayout = Component.getLayout || (page => page)
return getLayout(
<TestTheme>
<Component {...pageProps} />
</TestTheme>
)
} |
Beta Was this translation helpful? Give feedback.
8 replies
Answer selected by
junaid33
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First you need to install the latest version of next-themes and nextra
Then you should ba able to access the theme in _app.js