-
-
Notifications
You must be signed in to change notification settings - Fork 38
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
Wrong color applied to link when overriding MUI theme #77
Comments
Hi @sdornan, There is an ongoing PR in MUI that, I think, will fix this. See: mui/material-ui#32067 |
Thanks for the pointer! In that case, this can be closed. |
Hi @sdornan, If yes, are you using MUI link like this import Link from "@mui/material/Link";
<Link href="#" color="primary">Foo bar</Link> If not, where does the geenish color come from? |
Correct, the green color is my primary color in my theme. Since I am using Next.js, I'm using my own Link component that was adopted and customized from the Link component here: https://github.com/mui/material-ui/blob/master/examples/nextjs-with-typescript/src/Link.tsx Here's the component: https://gist.github.com/sdornan/ca308046d76b766758a157c1174bbe14 |
@sdornan, import * as React from 'react';
import Link from "@mui/material/Link";
import { createTheme, ThemeProvider } from '@mui/material/styles';
import createCache from "@emotion/cache";
import { CacheProvider } from "@emotion/react";
import { useStyles } from "tss-react/mui";
export const muiCache = createCache({
"key": "mui",
"prepend": true
});
const theme = createTheme({
"components": {
"MuiLink": {
"styleOverrides": {
"root": {
"color": "green",
},
},
},
}
});
function TestComponent() {
const { css } = useStyles();
return (
<React.Fragment>
<Link href="https://example.com" >This text should be green (from theme override)</Link>
<Link href="https://example.com" color="secondary" >This text should be purple (from prop secondary)</Link>
<Link href="https://example.com" color="secondary" className={css({ "color": "pink" })}>This text should be purple (from className)</Link>
</React.Fragment>
);
};
render(
<CacheProvider value={muiCache}>
<ThemeProvider theme={theme}>
<TestComponent />
</ThemeProvider>
</CacheProvider>
); I get this: Which is what I expect. |
That is the result I'd expect, but not the result I'm getting in my app. I'll continue to investigate and follow-up here. Thanks for your help so far! |
Are you using react 18? |
React 17.0.2 |
Hi, |
We have a Next.js application that we are in the midst of upgrading from MUI v4 to MUI v5 with react-tss. Part of our theme file is as follows:
In MUI v4, this color was correctly applied. However, in MUI v5 with react-tss, our link styles look like this:
It appears that instead of replacing the original
color
CSS property the new color is simply being added as an additional property. And unfortunately, probably based on the order styles are applied, the wrong color is taking precedence over the desired color. Any ideas here?The text was updated successfully, but these errors were encountered: