kradio3 / react-mdc-web

Material Design Components for React
https://kradio3.github.io/react-mdc-web/
MIT License
173 stars 25 forks source link

Ability to style Textfield elements using inline styles #58

Open ivmarkov opened 6 years ago

ivmarkov commented 6 years ago

See #57. For <Textfield> there is a similar (but not identical) issue. "...otherProps" are put on the <input> element, and not on the <div> (Field) element. While I see the rationale for this (very often you would like to push properties to the input element, as this is the one which interacts with the user), this precludes us from styling the Textfield element as a whole. For example, how am I supposed to make it occupy 100% width? Perhaps, I'm missing the elephant here...

ivmarkov commented 6 years ago

The problem is amplified when the Textfieldelement has a helptext, because then, besides the Field inner component, there is a div element wrapping the Fieldand the Helptext components which also needs styling.

The more I think about it, the more the issue seems to be related to styling only. In other words:

Perhaps it might help if we learn how other toolkits are doing it. Here's the rule in Material-UI:

ivmarkov commented 6 years ago

OK. So in the upcoming v1, Material UI seems to have given up completely on "Rule 1" from above. "xxxStyles" are nowhere to be seen. "Rule 2" seems to be 100% enforced though. The only thing they allow, in their Textfield Props is:

Would that work for us? E.g. follow a simple pattern where the user can supply a className string prop which is always assigned to the root element of the component, as well as one or more "xxxClassName" properties that - if supplied - will be assigned to the major sub-elements in the component's element tree? This seems like a simple change, which has the added benefit that it can be used with a CSS-in-JS or with regular CSS rules.

ivmarkov commented 6 years ago

Any feedback? Ability to style components is crucial if the library is to gain traction in the community...

kradio3 commented 6 years ago

Thank you for analyze, sure it make sense. I'll extend components by xxxClassName props.