-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
classes prop not working with emotion css. #17199
Comments
@feluxe See https://material-ui.com/guides/interoperability/#emotion |
@oliviertassinari Thanks for your reply, but I already saw the page that you linked to, I have actually quoted it above ;-) The given example doesn't solve the issue that I have. To put it simple: I know that this works: <Tabs css={css`padding: 5px;`} ... But how do I use emotion with the <Tabs classes={{ root: ???, indicator: ??? }} ... I tried with |
Maybe you don't need to use the classes API, what about the global class names? |
I'm not sure if it would suffice. I'll see if there is a way to transform the |
@feluxe I don't think that it's possible. I would personally use the global class names, like |
@feluxe Have you found what you've being searching for? |
@defusioner I didn't have the time to dig deeper into the issue. We decided not to use |
@defusioner You can target the global class names. e.g. <Button
css={css`
background: linear-gradient(45deg, #fe6b8b 30%, #ff8e53 90%);
border-radius: 3px;
border: 0;
color: white;
height: 48px;
padding: 0 30px;
box-shadow: 0 3px 5px 2px rgba(255, 105, 135, 0.3);
& .MuiButton-label {
color: papayawhip;
}
`}
>
Emotion
</Button> |
I've started to use emotion with So finally I create a |
@defusioner Does the |
@oliviertassinari I'm speaking about What is missing in the doc, is this example (passing an emotion class to the mui component): import { css, cx } from 'emotion'
const noWrap = css`
...styles
`
const conditionalClass = css`
...styles
`
<Tooltip
title={helpText}
placement={placement}
enterTouchDelay={0}
leaveTouchDelay={3000}
classes={{
popper: cx(noWrap),
tooltip: cx({ [conditionalClass]: condition })
}}
>
...
</Tooltip> |
@defusioner Thanks for the link, so it's not deprecated! The Tooltip case is interesting, as the tooltip escape the parent hierarchy (it renders with the body as a parent). This makes the usage of the css prop a challenge. We document a workaround with the styled API: https://material-ui.com/guides/interoperability/#portals (it works as well with emotion). In the case of @feluxe, it's much simpler, the tab children can be accessed with child CSS selectors ( |
@oliviertassinari I like much the approach of separating css-in-js "classes" into a separate file. I also find styled components approach of "decorating" components not brilliant in the way the final code looks like. I've liked the approach of this |
@oliviertassinari Thanks a lot for your example it works perfectly! For future reference, a code sandbox with this example can be found https://codesandbox.io/s/emotion-material-ui-global-css-example-pm8fx |
Current Behavior 😯
In the docs it says:
But when I try this:
The code (TypeScript) won't compile. I get this error:
Expected Behavior 🤔
makeStyles()
and emotion'scss
method should work together.Steps to Reproduce 🕹
See the use of
makeStyles()
in this code sandbox (It should highlight the error in the editor):https://codesandbox.io/s/emotion-typescript-example-v03mj?fontsize=14
Context 🔦
I'm trying to find out if we could use mui for our projects that use emotion for styling, but I'm stuck with this issue.
Is there maybe a plugin or something that I have missed to get emotion and mui work seamlessly together?
Your Environment 🌎
The text was updated successfully, but these errors were encountered: