material-tailwind icon indicating copy to clipboard operation
material-tailwind copied to clipboard

ThemeProvider + Remix

Open gvanderh opened this issue 3 years ago • 2 comments

Hi!

I'm trying to create a custom theme for a component as below in Remix (entry.client.jsx).

This yields a "Prop className did not match." warning (that disappears when the theme is not passed to the ThemeProvider) and the theme is not applied. Is this a bug in combination with Remix or am I doing something wrong?

import { ThemeProvider } from "@material-tailwind/react";

const theme = {
  button: {
    defaultProps: {
      variant: "outlined",
      color: "blue"
    }
  }
};

startTransition(() => {
  hydrateRoot(
    document,
    <StrictMode>
      <ThemeProvider value={theme}>
        <RemixBrowser />
      </ThemeProvider>
    </StrictMode>
  );
});

gvanderh avatar Nov 30 '23 17:11 gvanderh

It seems to be a "bug" in the documentation where it is only described to add ThemeProvider to entry.client. However, it also needs to be added to entry.server (wrapped around <RemixServer/>. This ensures client and server states are in sync.

gvanderh avatar Dec 01 '23 10:12 gvanderh

It seems to be a "bug" in the documentation where it is only described to add ThemeProvider to entry.client. However, it also needs to be added to entry.server (wrapped around <RemixServer/>. This ensures client and server states are in sync.

It works for me. Thanks.

53422245 avatar Feb 02 '24 05:02 53422245