Hi everyone,
I am trying to format some text for a runtime popup window and am looking for a way to set the text’s line height. USS does not seem to have a line-height property at this point.
Will this be added any time soon, or is there at least a way to achieve this with c# ?
Usually text size is defined by the font style settings. Do you have something you can share as an example?
I am referring to the spacing between each line in a label (with white-space set to normal in uss).
It would be great to control this similarly to css: https://www.w3schools.com/cssref/pr_dim_line-height.asp
Or am I missing something and this is already possible (without modifying the whole font)
In that case, no USS does not yet have the line-height equivalent.
You could always achieve this using other ways (your text element, be it Label, TextField, etc., could be added to a VisualElement that would have its align-items USS property set to flex-start and add a margin-bottom to that VisualElement to reflect the desired buffer height) but nothing as simple as the line-height unfortunately.
As a reference, you can always check here for supported properties:
Thanks for the suggestion.
That would only work with single line labels though, right? For a multiline label it would only add the margin to the bottom of the last line.
To make this work I would have to split each line into a separate label which seems really cumbersome.
Shocked this is not implemented yet.
We need line-height ASAP; this is 2022. Good modern layout and design requires this level of precision to create beautiful products that can compete in the marketplace. Every other major modern application UI framework has something equivalent.
Every little mistake adds up. Leading to what you see in the graph of Unity’s stock price below.
For the time being, you can set line height in the font asset file if that would work for you.
2023 do we have line-height yet? I can’t find it.
In UI toolkit can use rich text tags to setting line-height
<line-height=50%>Line height at 50%
This works for static content but how do I update the line height if I’m fetching my content dynamically like from a JSON?