Pixel line-height setting in iui-body considered harmful? #440
-
I just spent some time trying to track down why one of my elements became shorter after upgrading from 2.19 to 3.0, and eventually tracked it down to the line-height setting in iui-body. I can work around the problem by resetting that to normal, but it seems to me that it is a very bad idea to set that setting to a specific pixel value in iui-body, since that has such wide-ranging consequences. In my particular case my element contains large-ish text. Because of the global body-level line-height setting of 22px, space was not made to accommodate the larger text. This body-level setting means that (unless I am misunderstanding) anyone using itwinui is forced to set line-height to some other value any time they have any text anywhere that isn't the default size, and I feel that is very bad. Am I missing something? Is this hard-coded pixel setting providing some advantage that I'm just not seeing? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I think you're referring to itwin-core. They started using itwinui in 3.0. So there is no "change" from our side.
Setting line-height globally is a standard CSS practice because the default browser line-height is too small. What is debatable however is the use of a hardcoded pixel value. We are currently experimenting with switching to rem units in #424, so that should help a bit. We might also try using some fluid value (e.g.
Your concern about larger text is very valid, and this is an often thought-about problem. For now, you can either extend our typography variants or override the line-height on a case-by-case basis. |
Beta Was this translation helpful? Give feedback.
I think you're referring to itwin-core. They started using itwinui in 3.0. So there is no "change" from our side.
Setting line-height globally is a standard CSS practice because the default browser line-height is too small. What is debatable however is the use of a hardcoded pixel value. We are currently experimenting with switching to rem units in #424, so that should help a bit. We might also try using some fluid value (e.g.
line-height: calc(1em + 0.5rem)
) after researching a bit more.Your concern about larger text is very valid, and this is an often tho…