Link component does not understand custom theme colors #36318
Labels
component: link
This is the name of the generic UI component, not the React module!
customization: theme
Centered around the theming features
duplicate
This issue or pull request already exists
enhancement
This is not a bug, nor a new feature
Duplicates
Latest version
Steps to reproduce 🕹
Link to live example: https://codesandbox.io/s/serene-khorana-0gor3m
Create a custom palette color, e.g.
custom
, then render a Link component withcolor="custom"
.Current behavior 😯
You will get an error:
This seems to be due to how
Link
handles colors. It seems to work correctly if set the color to a standard CSS color value. It also works if I set it to any of the standard colors, e.gprimary
,secondary
. This comes from a check inLink.js
Expected behavior 🤔
To render a link with the color value specified in
custom.main
, consistently with what happens with non-custom values such asprimary
,secondary
, etc.The problem is that
colorTransformations
only contains colors defined in MUI but not ones added to the theme. I think this is a bug as it seems inconsistent with other components likeButton
.Context 🔦
I want to have the link have a color specified in theme, defaulting to the main value for that palette color.
Your environment 🌎
Company repo, cannot disclose. But the same happens on CodeSandbox.
Workaround 💡
Use
<Link color="custom.main">link</Link>
instead of<Link color="custom">link</Link>
The text was updated successfully, but these errors were encountered: