material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

IconButton default icon style not properly overriden by iconClassName

Open chris-verclytte opened this issue 9 years ago • 4 comments

Description

Currently IconButton default icon style is not properly overriden by iconClassName property. If I set following properties with closeIcon class overriding icon color's

<IconButton
   disableTouchRipple
   iconClassName={classNames('ion-md-close', classes.closeIcon)}
/>

I get instead, black color which is the default one.

Images & references

See how the element appears in the console : capture d ecran 2017-02-01 a 12 00 24 and the corresponding css rules: capture d ecran 2017-02-01 a 12 00 08 which leads to this render: capture d ecran 2017-02-01 a 11 59 59

Versions

  • Material-UI: 0.16.4

chris-verclytte avatar Feb 01 '17 11:02 chris-verclytte

That's expected, the inline-style has a higher specificity. We are referring to that point in the documentation. You have three options:

  1. Add !important when you need too.
  2. Override the style using the inline-style.
  3. Wait for the next branch that is moving away from the inline-style for that specific issue.

By the way, it's cool to see that convargo is using the lib. I have a friend working on truckfly.

oliviertassinari avatar Feb 01 '17 18:02 oliviertassinari

Since MUI uses inline JS styles, you have to include '!important' with every CSS style declaration.

i.e.

.my-class {
  margin: 0 !important;
}

If you use JS inline styles (with the props provided like 'iconStyle') you won't have to use '!important'

adepatie avatar Feb 01 '17 18:02 adepatie

@oliviertassinari Ok, I agree that inline-style has higher specificity than className has. But , I was expecting to have DEFAULT inline style overriden by className passed in props overriden by style passed in props as it seems to me that even if inline style is more specific it's DEFAULT behavior and props should always take precedence over the default style written inside components. But that's a matter of taste. Nevertheless, I missed the doc where it was explained so, thanks for the reminder ;)

Aside: Yes, to be honest, we were using the lib for our POC and we are now moving away because of new homemade design, but it was nice and helped us to build quickly ! 👍

chris-verclytte avatar Feb 02 '17 08:02 chris-verclytte

@chris-verclytte See ROADMAP.md on more info about the future of styling in this library.

adepatie avatar Feb 03 '17 16:02 adepatie