-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
Description
- The issue is present in the latest release.
- I have searched the issues of this repository and believe that this is not a duplicate.
In order to get fully fluent responsive experiences in the MUI components I setup all "sizing properties" to apply em unit if naked number is used as a value for them.
Current Behavior 😯
- I passed my custom settings to defaultUnit plugin in JSS with accordance to documentation

- Then I feed
StylesProviderwith such customized preset:

- Theme option for
htmlFontSizeI set to10. - And my reset CSS has

As a result, some of the properties in the default theme (which are originally implemented with unitless values) are becoming oversized.
Exemplary original styles implementation chunk of code:

This is happening because the implicit output unit (while using numbers only) for "sizes like properties" e.g. padding, margin is preassumed as px.
So when I have margin: 16 it becomes 16em in my scenario. Which produces 160px overblown margins, paddings, and so on in the default theme.
Like for example:
This enforces a lot of tedious override procedures in the theme, like:

Expected Behavior 🤔
For the originally set unitless values in the default theme I would expect one of scenario (starting from most appreciated):
- The values are recalculated to the respective
defaultUnitsettings in the JSS. So when I setdefaultUnittoemfor some CSS properties, the original implementation should recalculate all the unitless values based onhtmlFontSizeproperty in theme. Something like:
if (customDefaultUnit === 'em') unitlessProps.map(prop => (prop / theme.htmlFontSize);It's a pseudo code to get the basic concept.
This scenario would create full responsive (proportional sizing) across all the styling in the default theme.
2. Default unitless props are becoming hardcoded to pixel-units in case if defaultUnit plugin is changed.
This would make some theme props output as pixel-sized, which would create an inconsistent sizing pattern. But at least it would not break the theme while customizing the defaultUnit JSS preset.
3. Make the unitless concept of theming out of the theming, and make everything pixel-based. Very grim scenario but at least consistent and not brittle.
Steps to Reproduce 🕹
I hope the above explanation is enough. I will provide a working example if necessary.
Context 🔦
CSS theme that uses only proportional sizing (em, rem %) in order to get the best responsive UI experiences and simplify the process of customizing styles.
Currently, part of the API support this task like font sizing but some of the props (as described above) produce fixed pixel values which output as an inconsistent theme (some values are em and some px). This enforces many tedious overrides in theme in order to get proper responsive "fluid" results.
I don't know if this type of issue "the Bug" (I guess it is something between the Bug and request to Change functionality) applies to the described scenario. So please amend accordingly. I might, of course, miss some documentation and do things just wrong. So please direct in the better implementation suggestions.
Your Environment 🌎
| Tech | Version |
|---|---|
| Material-UI | v4.9.14 |
| React | v16.13.1 |
| Browser | ["last 1 version", "> 0.5%", "not dead"] |
| TypeScript | v3.8.3 |