Skip to content

Hello World Example

The Hello World example demonstrates the most basic usage of Elaris.UI - creating an application, adding widgets, and running it.

  • Creating an Application instance
  • Creating a Frame widget with borders
  • Adding Label widgets
  • Running the application
  • Basic color usage
using System.Drawing;
using Ambystech.Elaris.UI;
using Ambystech.Elaris.UI.Core;
using Ambystech.Elaris.UI.Enums;
using Ambystech.Elaris.UI.Widgets.Display;
using Ambystech.Elaris.UI.Widgets.Layout;
var app = new Application();
var mainFrame = new Frame("Hello Elaris!")
{
BorderStyle = BorderStyle.Rounded,
ForegroundColor = ColorHelper.FromRgb(100, 200, 255),
};
var label = new Label("Welcome to Elaris CLI UI Library!")
{
X = 2,
Y = 2,
Width = 50,
Height = 1,
ForegroundColor = ColorHelper.FromRgb(255, 200, 100),
Bold = true
};
var infoLabel = new Label("Press ESC or Ctrl+C to exit")
{
X = 2,
Y = 4,
Width = 50,
Height = 1,
ForegroundColor = Color.Gray
};
mainFrame.Add(label);
mainFrame.Add(infoLabel);
app.Run(mainFrame);
  1. Application Creation: new Application() creates the main application instance
  2. Frame Widget: Creates a bordered container with a title
  3. Label Widgets: Display text with colors and styling
  4. Widget Hierarchy: Adding widgets to the frame using Add()
  5. Running: app.Run() starts the event loop
Terminal window
cd examples/Elaris.Examples.HelloWorld
dotnet run
  • Every Elaris.UI application needs an Application instance
  • Widgets are added to containers using Add()
  • Colors can be created using ColorHelper.FromRgb()
  • The application runs until ESC or Ctrl+C is pressed