Label
The Label widget displays text with support for styling and alignment options.
Overview
Section titled “Overview”Label is one of the most basic widgets in Elaris.UI. It’s used to display static or dynamic text with various formatting options.
Properties
Section titled “Properties”Text (string)
Section titled “Text (string)”The text to display. Supports multi-line text (use \n for line breaks).
label.Text = "Hello, World!";label.Text = "Line 1\nLine 2";Bold (bool)
Section titled “Bold (bool)”Whether the text is displayed in bold.
label.Bold = true;Italic (bool)
Section titled “Italic (bool)”Whether the text is displayed in italic.
label.Italic = true;Underline (bool)
Section titled “Underline (bool)”Whether the text is displayed with underline.
label.Underline = true;HorizontalAlignment (HorizontalAlignment)
Section titled “HorizontalAlignment (HorizontalAlignment)”Horizontal text alignment:
Left(default)CenterRight
label.HorizontalAlignment = HorizontalAlignment.Center;VerticalAlignment (VerticalAlignment)
Section titled “VerticalAlignment (VerticalAlignment)”Vertical text alignment:
Top(default)MiddleBottom
label.VerticalAlignment = VerticalAlignment.Middle;Usage Example
Section titled “Usage Example”var label = new Label("Welcome to Elaris!"){ X = 10, Y = 5, Width = 50, Height = 3, ForegroundColor = ColorHelper.FromRgb(255, 200, 100), BackgroundColor = Color.Black, Bold = true, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Middle};Multi-line Text
Section titled “Multi-line Text”Labels support multi-line text:
label.Text = "First line\nSecond line\nThird line";Each line is aligned according to HorizontalAlignment and VerticalAlignment.
Related Widgets
Section titled “Related Widgets”- TextView - For scrollable multi-line text
- Base Widget - Base class documentation