Closed IsenrichO closed 7 years ago
Because font-line-height prop is non-standard, it is handled separately https://github.com/cssinjs/jss-default-unit/blob/master/src/defaultUnits.js#L108
Btw. lineHeight is a unit that can be unitless in CSS , consider not using defaults for this case.
In general, I prefer to use line-height
without units... or, at least that's what I learnt was a best practice for that particular CSS property. However, we are in the practice of always using it with pixels at my place of work. In that spirit, I was interested in setting a default unit for the property.
To clarify, are you saying that using font-line-height: 'px'
should work?
However, we are in the practice of always using it with pixels at my place of work.
Maybe you really shouldn't, line-height should stay in proportion to font-size and unitles value is the right way to do so.
To clarify, are you saying that using font-line-height: 'px' should work?
It should
Awesome! Thanks for the help @kof !
Having tried this now, I am finding that using 'font-line-height': 'px'
does not work.
Are grid-layout styles considered by default unit?
I'm doing the following now: gridRowGap: theme.spacing + 'px'
@IsenrichO how did you solve the lineHeight default as px issue?
Neither is working:
fontSize: 18,
fontLineHeight: 27, // not working, getting font-line-height: 21px;
fontSize: 18,
lineHeight: 27, // not working, getting line-height: 21; (the unitless instead of px)
@damianobarbati you will need to explicitly set the default unit of the line-height prop to be pixels:
const defaultUnitOptions = {
'line-height': 'px',
};
const presetOptions = {
defaultUnit: defaultUnitOptions,
};
const jssInstance = create(Preset(presetOptions));
Oh no... anything less verbose and not requiring to import-then-configure presets? 😞
All I'm doing right now is just:
import { jss, ThemeProvider } from 'react-jss';
lineHeight is a unitless property in css by design, use it that way without unit, its better
@kof you're totally right, using the default unitless: defintely more robust.
The JSS-Default-Unit package does not work properly for the
line-height
property when used in conjunction with the JSS-Expand plugin.To clarify, the jss-expand docs show that the
line-height
property may be nested insidefont
as so:My config is given below:
I have found that when I specify a
lineHeight
that is not nested insidefont
, it works as expected. For example,However, when nesting
lineHeight
withinfont
(as jss-expand should allow), it fails to work properly. For example,