Hi,
I cannot seem to figure out how to wrap a label’s text if it exceeds its parent’s content area. What is the recommended way to do so?
Thanks in advance.
Hi,
I cannot seem to figure out how to wrap a label’s text if it exceeds its parent’s content area. What is the recommended way to do so?
Thanks in advance.
Use the uss property
{
white-space: normal;
}
Unintuitive I know but that’s what it does!
Have come back to this innumerable times whenever I forget the name of the property. Thanks!
What is the way to do this same thing from a C# script?
There are multiple ways of doing it programmatically. You could do something like this when initializing a field, but this would apply the style inline.
Label label = new Label()
{
style =
{
fontSize = 12,
whiteSpace = WhiteSpace.Normal
}
};
Alternatively, you could still rely on USS like so:
USS:
.wrap
{
white-space: normal;
}
C#:
label.AddToClassList(".wrap");