creativetimofficial / material-tailwind

@material-tailwind is an easy-to-use components library for Tailwind CSS and Material Design.
https://material-tailwind.com/
MIT License
3.51k stars 307 forks source link

ThemeProvider + Remix #516

Open gvanderh opened 7 months ago

gvanderh commented 7 months ago

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 commented 7 months ago

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.

53422245 commented 5 months ago

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.