-
-
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
[styled-engine-sc] TS error when using a css
-variable within styled
#40140
Comments
@delijah I have fixed this issue by just removing css from colors variable, you can refer the screenshot below |
Thank you @KumarNitin19 for your suggestion. If i do so, i get the following TS error for the theme argument variable: Which makes sense, because how should TS know what And using the type any, like you do in your example, is not really a solution for us. We need a proper typed theme variable within our css code. |
Hey @delijah can you please refer below screenshot for this bug, feel free to check out this codesandbox: https://codesandbox.io/p/devbox/mui-theme-scoping-within-css-and-css-within-styled-forked-pykhvq? |
Thanks again for you suggestion @KumarNitin19. We are actually not looking for a quickfix. I assume there are several ways of somehow getting around the bug. |
@zannager @siriwatknp Added our support key to the issue description. |
css
-variable within styled
css
-variable within styled
It is related to using |
Yes, it looks like with the default installation it works fine. But not, as you're suggesting, with |
I am curious in general and I always tend to ask this question :) Why have you decided to go with @mui/styled-engine-sc? I am asking because there are known issues for e.g. with SSR (see https://mui.com/material-ui/guides/styled-components/). I am taking a look at the issue now. |
I will look into the typing issue, I agree the On the second issue around having to use THEME ID, the reasoning for this is that the the |
Sure :) Basically because we already use styled-components all over our stack and we do not want to add an extra dependency which we do not use anywhere. We do not use SSR and we will not in the future, therefore we are happy to not have to rely on that :) |
I missed this one. Developer should not need to access the THEME_ID, the |
Thanks @siriwatknp I will leave that one to you, and I will try to resolve the TypeScript issue by next week. |
Hello @siriwatknp and @mnajdova . I've created two PR's which solve part 1 and 2 of this issue: Looking forward 😃 |
Duplicates
Latest version
Steps to reproduce 🕹
Link to live example: https://codesandbox.io/p/devbox/mui-theme-scoping-within-css-and-css-within-styled-knpr8m?file=%2Fsrc%2FApp.tsx
Steps:
Current behavior 😯
css
-variable withinstyled
:Property 'variants' is missing in type 'Interpolation<object>[]' but required in type 'CSSObjectWithVariants<any>'.
THEME_ID
to access the MUI themeExpected behavior 🤔
css
-variable withinstyled
, without getting a TS error.css
. There should be no need to use theTHEME_ID
variableContext 🔦
We try to use MUI with theme scoping with styled-components v6.
Your environment 🌎
npx @mui/envinfo
Support Key
#80425
The text was updated successfully, but these errors were encountered: