Skip to content

Custom Theme is not SSR? App styles flicker on page load. #286

Answered by jrgarciadev
eleazareramos asked this question in Help
Discussion options

You must be logged in to vote

Hey @eleazareramos I was looking into this subject and you are right NextUI has a flash theme switch when you set custom values, in the meanwhile, you can use next-themes for fixing it as follows:

// _app.js

import { createTheme, NextUIProvider } from "@nextui-org/react";
import { ThemeProvider as NextThemesProvider } from "next-themes";

const customTheme = createTheme({
    type: "dark",
    theme: {
        colors: {
	   primary: "#AAFFEC",
        },
    },
});

function App({ Component, pageProps }) {
  return (
    <NextThemesProvider
	  defaultTheme="system"
	  attribute="class"
	  value={{
	    dark: customTheme.className,
	  }}
    >
	<NextUIProvider>
           <Component {...p…

Replies: 5 comments 4 replies

Comment options

You must be logged in to vote
3 replies
@eleazareramos
Comment options

@devbravo
Comment options

@antoinelin
Comment options

Answer selected by jrgarciadev
Comment options

You must be logged in to vote
1 reply
@zvictor
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
8 participants