Skip to content
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

Icon component can't receive custom theme colors #27831

Closed
2 tasks done
benmneb opened this issue Aug 18, 2021 · 2 comments · Fixed by #27923
Closed
2 tasks done

Icon component can't receive custom theme colors #27831

benmneb opened this issue Aug 18, 2021 · 2 comments · Fixed by #27923
Assignees
Labels
bug 🐛 Something doesn't work v5.x

Comments

@benmneb
Copy link
Contributor

benmneb commented Aug 18, 2021

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

Icon component can't receive custom theme colors, while Buttons and IconButtons can.

Expected Behavior 🤔

Icon component can receive custom colors from the theme, just like Buttons and IconButtons can.

Steps to Reproduce 🕹

CodeSandbox

Steps:

  1. Add custom color to theme
  2. Apply it to IconButton and a regular Mui Icon
  3. Watch it work on IconButtons
  4. And not work on Icons

Context 🔦

Trying to custom style Icons and Button start/endIcons without them being IconButtons.

Your Environment 🌎

`npx @material-ui/envinfo`
System:
    OS: macOS 11.4
  Binaries:
    Node: 14.17.4 - ~/.nvm/versions/node/v14.17.4/bin/node
    Yarn: 3.0.1 - ~/.nvm/versions/node/v14.17.4/bin/yarn
    npm: 7.20.6 - ~/.nvm/versions/node/v14.17.4/bin/npm
  Browsers:
    Chrome: Not Found
    Edge: Not Found
    Firefox: Not Found
    Safari: 14.1.1
  npmPackages:
    @emotion/react: ^11.4.1 => 11.4.1 
    @emotion/styled: ^11.3.0 => 11.3.0 
    @material-ui/core: next => 5.0.0-beta.4 
    @material-ui/icons: next => 5.0.0-beta.4 
    @material-ui/private-theming:  5.0.0-beta.4 
    @material-ui/styled-engine:  5.0.0-beta.4 
    @material-ui/system:  5.0.0-beta.4 
    @material-ui/types:  6.0.2 
    @material-ui/unstyled:  5.0.0-alpha.43 
    @material-ui/utils:  5.0.0-beta.4 
    @types/react:  17.0.18 
    react: ^17.0.2 => 17.0.2 
    react-dom: ^17.0.2 => 17.0.2 

This behaves the same on Firefox and Chrome (haven't checked Safari or Edge) and Codesandbox...

🙏🙏🙏

@benmneb benmneb added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Aug 18, 2021
@AlvesJorge
Copy link
Contributor

AlvesJorge commented Aug 18, 2021

Hi Ben,
While I wasn't able to find out why this is happening ( and I would love to know why ) I found a workaround that could be an easy fix for you , and a guidance to why this might be happening to someone more experienced in MUI that might see this.
https://codesandbox.io/s/material-ui-v5-icons-custom-color-bug-forked-jswdn?file=/demo.js
By using "warning" which is one of the listed values for the color prop for the SvgIcon , you can now use it as your custom color palette.
image
Interestingly enough , IconButton api doesn't reference any "custom values" yet it works in that . Go Figure.
Hope this helps!

@benmneb
Copy link
Contributor Author

benmneb commented Aug 18, 2021 via email

@eps1lon eps1lon added bug 🐛 Something doesn't work and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Aug 23, 2021
@eps1lon eps1lon self-assigned this Aug 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work v5.x
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants