-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
[link] Link component adds additional class with custom styles without any reason #30139
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
Comments
That class is generated by emotion and contains all styles that MUI defines for this component. One of that style is the margin. See:
Which styles does it rewrite? What are you trying to solve? |
@mnajdova it rewrites my custom margins. Is it possible to disable it? Or move those styles before my custom ones? |
@mnajdova I've updated the example in https://codesandbox.io/s/react-mui-forked-0sewm so you can see, that the margin for the Link component in App component is rewritten by that custom class |
Ideally none of the components would have a
|
The codesandbox is not working, the |
Fixed codesandbox. I have custom margins, adding it to a parent selector for every link will require a lot of work, that's definitely not a nice BC. |
The issue here is that you are using |
It is possible to remove the other classes that doesn't have any styles defined from the HTML? |
Currently not, but we discussed this at some point with @michaldudak. I would be curious to know what is the reason you would want that @montogeek |
@mnajdova To keep the HTML clean |
Alright, fair enough, cc @michaldudak @siriwatknp I am adding this to the v6 milestone so that we can make a decision on this going forward. |
@mnajdova The docs for Link component says that it also accepts Typography props. The props Applying a bottom margin to a text/link component is a pretty common and reasonable need Please consider addressing this as a v5 patch. Thanks! |
For anyone else looking at this, a decent workaround is like so:
That way you can still get the built-in Link styles and apply Typography props, including bottom margin Not a great DX though |
Setting |
textAlign props don't really work great on links either, because they're inline maybe? I think a larger overhaul of the Link/Typography connection is needed. It's convenient to have Link accept Typography props but there are a lot of undocumented edge cases that don't work as expected |
I see no root problems on this issue related to the
How about we close it? |
Current behavior 😯
Link component adds a class named css-XXXXXXX-MuiTypography-root-MuiLink-root to "a" tag with custom styles, this breaks all my markup because it has "margin: 0" rule and it always comes last and rewrites all other styles. The documentation doesn't mention this behavior.
Expected behavior 🤔
A tag without additional class
Steps to reproduce 🕹
Steps:
https://codesandbox.io/s/react-mui-forked-0sewm
Context 🔦
No response
Your environment 🌎
`npx @mui/envinfo`
The text was updated successfully, but these errors were encountered: