Description
The PreLine
field is a member of the WhiteSpace
enumeration within the Sandbox.UI
namespace. It specifies that sequences of white spaces are collapsed, text will wrap when necessary, and linebreaks are preserved. This is useful for maintaining the structure of text while allowing it to adapt to different container sizes.
Usage
Use the WhiteSpace.PreLine
enumeration value when you want to ensure that line breaks in the source text are preserved, but you also want the text to wrap within its container. This is particularly useful for displaying preformatted text that should still be responsive to layout changes.
Example
// Example of using WhiteSpace.PreLine in a UI component
var label = new Label();
label.Style.Set("white-space", WhiteSpace.PreLine);
label.Text = "This is a text with\nline breaks that should be preserved.";