Material UI StyledEngineProvider not working with styled components

Viewed 300

I've tried using both StylesProvider and StyledEngineProvider to override material UI classes and it works for a split second but then styling reverts back to base classes. I'm using styled components.

You can see the live example here: https://main.d285b8tmdxl7or.amplifyapp.com/ Take a look at the nav links at render and after a second.

Here's my index Page:

import React from "react";
import {
  createTheme,
  ThemeProvider,
  responsiveFontSizes,
} from "@mui/material/styles";
import CssBaseline from "@mui/material/CssBaseline";
import { StylesProvider } from "@mui/styles";
import StyledEngineProvider from "@mui/material/StyledEngineProvider";
...
const IndexPage = () => {
  return (
    <StyledEngineProvider injectFirst>
      <ThemeProvider theme={mainTheme}>
        <CssBaseline />
        <Layout>
          <HeroSection />
          <ClientLogoBar />
          <CaseStudies />
          <WhatMakesDifferent />
          <Services />
          <FlagBanner />
          <ClientTestimonials />
          <EndRace />
        </Layout>
      </ThemeProvider>
    </StyledEngineProvider>
  );
};

export default IndexPage;
0 Answers
Related