Skip to content

Label

The Label widget displays text with support for styling and alignment options.

Label is one of the most basic widgets in Elaris.UI. It’s used to display static or dynamic text with various formatting options.

The text to display. Supports multi-line text (use \n for line breaks).

label.Text = "Hello, World!";
label.Text = "Line 1\nLine 2";

Whether the text is displayed in bold.

label.Bold = true;

Whether the text is displayed in italic.

label.Italic = true;

Whether the text is displayed with underline.

label.Underline = true;

Horizontal text alignment:

  • Left (default)
  • Center
  • Right
label.HorizontalAlignment = HorizontalAlignment.Center;

Vertical text alignment:

  • Top (default)
  • Middle
  • Bottom
label.VerticalAlignment = VerticalAlignment.Middle;
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
};

Labels support multi-line text:

label.Text = "First line\nSecond line\nThird line";

Each line is aligned according to HorizontalAlignment and VerticalAlignment.