This is POC of using Tailwind CSS with Material-UI.
The idea is to sync MUI theme with Tailwind CSS theme. To do that, we need to get tailwind theme from the MUI theme creation function to inject Tailwind value into the MUI theme properties.
tailwind.config.js
needs to be in the ./src
folder to be imported
into the React App and MUI theme. To do that, edit craco.config.js
to:module.exports = {
style: {
postcss: {
plugins: [
require("tailwindcss")("./src/tailwind.config.js"),
require("autoprefixer"),
],
},
},
};
⚠️ Notice the tailwind.config.js path after requiring tailwindcss.
// ./src/App.js
const tailwindConfig = resolveConfig(tailwindConfigModule);
const theme = createMuiTheme({
palette: {
primary: {
main: tailwindConfig.theme.colors.primary.main,
},
},
});