-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
[joy-ui][icons][system] Replace @mui/material dependency with @mui/system #35637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v5.x
Are you sure you want to change the base?
Conversation
Netlify deploy previewBundle size report |
|
The argos difference comes from the usage of This is one unfortunate breaking change. I wonder if it will really have an impact, as the users of the library will most likely have a One way for fixing it, would be to duplicate the Material Design theme inside the @mui/icons-material and use that one as default theme or create a dedicated package for the theme itself that both @mui/material and @mui/icons-material can depend on. This is how it would look like: #35652 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes sense to me for v6 👍.
| * | ||
| * - [SvgIcon API](https://mui.com/material-ui/api/svg-icon/) | ||
| */ | ||
| const SvgIcon = React.forwardRef(function SvgIcon(inProps, ref) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would imagine that SvgIcon will eventually go inside @mui/system because once we add a new set of icons for Joy UI 1. Will we duplicate SvgIcon again? 2. Won't we want to have Material UI users be able to import these new icons without loading Joy UI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was my first implementation too, but honestly SvgIcon in different libraries, will likely have different styles, this is why I've decided to move it to the icons package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But then, maybe it means that we should solve #21251 and let the developers import SvgIcon from the right package?
import SvgIconMd from '@mui/material/SvgIcon';
import SvgIconJoy from '@mui/joy/SvgIcon';
import EditIcon from '@mui/icons-material/Edit';
<SvgIconMd>
<EditIcon />
</SvgIconMd>It's a fallback method of FontAwesome: https://fontawesome.com/docs/web/use-with/react/add-icons#add-individual-icons-explicitly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't put SvgIcon in the common package, at least in its current shape. It is tailored specifically for Material Design icons (sizes, viewport) and shouldn't be used with arbitrary icons (despite its generic name). If we create another icon set in the future, it can have its own SvgIcon. We could extract the common parts into a Base component if there is a lot of duplication between different packages' versions.
In general, I like the approach from #35652 a bit more. It's a change that shouldn't break anyone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is tailored specifically for Material Design icons (sizes, viewport)
I don't think that these are fundamentally specific to Material Design or Joy UI. We document how it can be used with random SVG path in https://mui.com/material-ui/icons/#font-awesome and are using it for the same use case as well. IMHO, the value of this component is to apply a few better default: attributes, a11y resets, CSS resets, that developer would want. It's also to provide the MUI System style helper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can publish a generic SvgIcon without the defaults tailored for Material Icons and icon set-specific versions so the sizes don't have to be overridden.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But then, maybe it means that we should solve #21251 and let the developers import SvgIcon from the right package?
import SvgIconMd from '@mui/material/SvgIcon'; import SvgIconJoy from '@mui/joy/SvgIcon'; import EditIcon from '@mui/icons-material/Edit'; <SvgIconMd> <EditIcon /> </SvgIconMd>
While this is great for a fallback method, I don't think this should be the default for a icons package we provide. I would rather have two icons packages for material & joy instead of this. However, compared to this, I think the PR's solution is still a good enough replacement.
+1 for exporting an SvgIcon for itegrating with third party icon sets.
Signed-off-by: Marija Najdova <[email protected]>
…s/remove-material-ui-dependency
…s/remove-material-ui-dependency
|
@mnajdova With the latest change:
|
|
@siriwatknp your changes are somewhat in the middle between the initial aim of this PR and #35652 which I created back then as an alternative, I think it's worth exploring 👌
I would disagree here, the
We should keep the old export for backward compatibility.
👌 |
🤔 I doubt this. I think one selling point of Material UI is being used without creating an empty theme. I think we should keep this PR non-breaking changes. Otherwise, this PR should be revisited in v6 since it is a breaking change. If we want to continue this PR in v5, we can improve #35652 by writing a script that will read the Material UI default theme and copy those values as a default theme of Icons. As you can see, the default theme is more maintainable compared to #35652. We can also add a CI to run the script to help us detect changes in Material UI default theme so that the author does not forget to update icon default theme. |
Exactly my point, this is why I mentioned it, we can't merge this as is right now.
Regardless of whether we automate this process or have a separate package, the disadvantage is the same - we end up with the theme bundle if you use the Material UI icons package, regardless of whether you need it or not. |
|
It's unfortunate that this no longer seems to be part of the v6 roadmap -- the intent to remove the If this is no longer going to be part of v6, maybe the alternatives suggested in #35652 should be reevaluated, so there will be some solution on the horizon, even if that involves some trade-offs? To add a bit more context for why removing the dependency is important, one thing I haven't seen anyone mention is that with the status quo, it seems impossible to use JoyUI, Material Icons, and DataGrid (or any other MUI X components) together. Using JoyUI + Material Icons requires this resolution hack, and the resolution hack breaks MUI X. (Or, at least it does for users of The main reason for not doing something like #35652 seemed to be bundle size -- but personally I would prefer a bigger bundle that doesn't have interoperability problems, vs a smaller one that does. |
It really is unfortunate, I was actually betting on it being done sooner. Now I'm starting to wonder what would it take to get this done🤔 |
|
@zacronos sorry for responding a bit late, I had a lot of notifications. If bundle size is not an issue for you, you can just use Joy UI, Material UI, Material UI Icons and the DataGrid altogether. Have you tried this? Is this not working at this moment? |
|
@mnajdova thanks for the response, late is better than never. 😄 I don't believe it works to use them all together, no -- though maybe I'm doing it wrong somehow? In the
Is that incorrect? If the only reason for using that workaround is for bundle size, then maybe they can all work together. When following those instructions as stated, however, it seems it is impossible to use MUIX components like DataGrid. I could remove the resolution hack, and see if everything works when simply installing all 4 dependencies, as you suggest. |
You can skip this step if you are okay to have @mui/material installed and in the bundle too. This was exactly my point. Also, tree shaking works, so eventually you would end up with the theme and few utils that are used in the icons, which is still not ideal, but not the end of the world too :) |
|
Got it, thank you for the clarification @mnajdova! I'll give that a try next time I'm making changes in that area of the code. |

closes #34489
issue: https://codesandbox.io/s/882s3v?file=/src/Demo.js
This PR aims to remove the
@mui/materialdependency from@mui/icons-material, by making the package depend on the @mui/system. This will allow us to use the package with @mui/joy much more easily, by just providing a style override for theSvgIconwithout the need for yarn resolution.TODOs:
Update joy's default theme to add overrides for the- was done alreadySvgIconfontSizeandcolor(the typings should work by default). [tested]