[POC] Use ThemeCSSProvider as replacement for ThemeProvider#48652
[POC] Use ThemeCSSProvider as replacement for ThemeProvider#48652silviuaavram wants to merge 12 commits into
Conversation
Deploy preview
Bundle size
Check out the code infra dashboard for more information about this PR. |
There was a problem hiding this comment.
Pull request overview
Adds a new @mui/tailwind package as a POC integration layer between MUI’s CSS variables (from CssVarsProvider) and Tailwind (v3 preset + v4 CSS directives), and wires it into the docs with a new integration page and demos.
Changes:
- Introduce
@mui/tailwind(Tailwind v3 preset + state-variant plugin + Tailwind v4v4.csstoken mapping). - Update docs to consume
@mui/tailwind/v4.cssand add a new “Tailwind components” integration page + demos. - Adjust repo config/deps to include the new workspace package and remove
postcss-importfrom docs.
Reviewed changes
Copilot reviewed 18 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tsconfig.json | Adds TS path aliases for the new @mui/tailwind package. |
| pnpm-lock.yaml | Adds workspace link for @mui/tailwind and updates lock entries (incl. removal of postcss-import). |
| packages/mui-tailwind/src/v4.css | Tailwind v4 CSS integration: breakpoints, token mapping, utilities, and mui-* variants. |
| packages/mui-tailwind/src/preset.js | Tailwind v3 preset exposing MUI token mappings + plugin registration. |
| packages/mui-tailwind/src/plugin.js | Tailwind plugin adding mui-{state} / mui-not-{state} variants. |
| packages/mui-tailwind/README.md | Links to the docs integration page for setup and demos. |
| packages/mui-tailwind/package.json | Declares the new package metadata and entrypoint exports. |
| docs/postcss.config.js | Removes postcss-import from the docs PostCSS pipeline. |
| docs/pages/material-ui/integrations/tailwindcss/tailwindcss-components.js | Adds a new docs route for the Tailwind components page. |
| docs/pages/global.css | Imports @mui/tailwind/v4.css and updates layer ordering for Tailwind/MUI. |
| docs/package.json | Adds @mui/tailwind workspace dependency; removes postcss-import. |
| docs/data/material/integrations/tailwindcss/TailwindFilterChips.tsx | New TS demo using mui-selected: Tailwind variant on MUI ToggleButtons. |
| docs/data/material/integrations/tailwindcss/TailwindFilterChips.js | JS version of the filter chips demo. |
| docs/data/material/integrations/tailwindcss/TailwindDisabledState.tsx | New TS demo using mui-disabled: variant with Slider/Switch. |
| docs/data/material/integrations/tailwindcss/TailwindDisabledState.js | JS version of the disabled-state demo. |
| docs/data/material/integrations/tailwindcss/tailwindcss-v4.md | Points readers to the new @mui/tailwind package page. |
| docs/data/material/integrations/tailwindcss/tailwindcss-components.md | New docs page describing @mui/tailwind setup (v3 + v4) and demos. |
| docs/data/material/integrations/tailwindcss/TailwindCard.tsx.preview | Preview snippet for the Tailwind job card demo. |
| docs/data/material/integrations/tailwindcss/TailwindCard.tsx | New TS Tailwind-styled job card demo built from MUI components. |
| docs/data/material/integrations/tailwindcss/TailwindCard.js | JS version of the Tailwind job card demo (+ PropTypes). |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
39e2999 to
8b43394
Compare
128c3ce to
0c748fd
Compare
0c748fd to
da7fa88
Compare
| react(), | ||
| ], | ||
| resolve: { | ||
| alias: [ |
There was a problem hiding this comment.
You should remove these aliases and test against the build folders instead. These aliases tend to turn what's supposedly 3rd party code for bundlers into 1st party code. Which operates under different rules in some runtimes. In the past I've also masks module graph issues around csj/esm.
There was a problem hiding this comment.
sure, let me check.
This PR aims to act as a POC for using a CSSThemeProvider instead of ThemeProvider, which should not import anything Emotion related. To be used by consumers who want to replace Emotion styling with anything else: Tailwind, CSS Modules etc. It's one of the ways we can remove Emotion and keep the Theme generation at runtime. The other way is to generate the theme at build time and import the file. This PR will cover just the first option.
Progress:
@mui/tailwindpackage.docs/data/material/integrations/tailwindcss/tailwindcss-components.md.postcss-importanymore, as it also broke the import from @mui/tailwind.Sliderto use css file instead of using styled arguments. At the moment, the only option I can make it with CSS modules file.composeClassesto build the class name and also check the css modules object for the corresponding hashed class, and add it to the result when found.transitionvariables and also make sure they havemsinstead ofpxmeasurement.@mui/styled-engine-noopThemeProviderandCSSThemeProvider, as well as 2 experiments in the docs app (css + emotion)useColorSchemesupport for both examples and to make it work via CSSThemeProvideruseCSSColorSchemewhich is a separate export, due to the fact thatuseColorSchemefromCSSVarsProvideris coupled with the implementation.useColorScheme/useCSSColorSchemeis now abstracted inuseColorSchemeSetup.sx,styleOverridesandstyletag to changeSlider. For css example in experiments,styleOverridesdoes not work, butsxdoes (no alias to style-noop). For css example in vite,sxandstyleOverridesdo not work.Testing:
pnpm startand checkhttp://localhost:3000/experiments/css-slider/andhttp://localhost:3000/experiments/emotion-slider/. The experiments are in the source code.style-noopin the case of CssThemeProvider, runpnpm -F @mui-internal/css-theme-provider-vite-sandbox devandpnpm -F @mui-internal/emotion-vite-sandbox dev. Check the links provided by the commands.pnpm -F @mui-internal/emotion-vite-sandbox buildandpnpm -F @mui-internal/css-theme-provider-vite-sandbox build.