A modern, extensible Text User Interface (TUI) library for .NET that provides rich terminal UI components built on Spectre.Console. Create interactive console applications with styled text, borders, layouts, and keyboard input handling using clean, object-oriented APIs. Features modular architecture with dependency injection support, cross-platform compatibility, and comprehensive styling options for professional terminal applications.
$ dotnet add package ktsu.TUI.CoreA modern, extensible Text User Interface (TUI) library for .NET applications built on top of Spectre.Console. This library provides a clean, object-oriented approach to building interactive terminal applications with rich visual features.
ktsu.TUI is designed with SOLID principles and provides a modular architecture for creating terminal-based user interfaces. It features:
✓ Rich Text Styling: Bold, italic, underline, colors, and background colors
✓ Border Elements: Multiple border styles (single, double, rounded, thick, ASCII, none)
✓ Layout System: Stack panels with horizontal/vertical orientation and spacing
✓ Input Handling: Keyboard input processing with ESC to exit
✓ Alignment Support: Horizontal and vertical text alignment
✓ Padding & Positioning: Flexible positioning and padding system
✓ Responsive Design: Automatic sizing based on content and container dimensions
Contracts → Models → Services
↓ ↓ ↓
Elements → Layouts → Primitives
↓
Provider Abstraction
Add the NuGet package:
dotnet add package ktsu.TUI
using ktsu.TUI.Core.Services;
using ktsu.TUI.Core.Elements.Primitives;
using ktsu.TUI.Core.Elements.Layouts;
using ktsu.TUI.Core.Models;
// Create console provider
var consoleProvider = new SpectreConsoleProvider();
// Create a simple UI
var ui = new BorderElement
{
Title = "My TUI App",
BorderStyle = BorderStyle.Double,
Child = new TextElement
{
Text = "Hello, TUI World!",
Style = new TextStyle { IsBold = true, Foreground = "green" }
}
};
// Create and run application
var app = UIApplication.CreateBuilder(consoleProvider)
.UseRootElement(ui)
.Build();
await app.RunAsync();
The library includes several demonstration applications:
--interactive)--showcase)Run demos:
dotnet run --project TUI.App # Sample app
dotnet run --project TUI.App -- --interactive # Interactive demo
dotnet run --project TUI.App -- --showcase # Showcase demo
TextElement: Styled text displayBorderElement: Bordered containers with titlesStackPanel: Horizontal/vertical layout containerTextStyle: Font styling (bold, italic, underline, colors)BorderStyle: Border appearance (single, double, rounded, etc.)Padding: Space around contentPosition: Element positioningThis project follows clean architecture principles and emphasizes:
MIT License. Copyright (c) ktsu.dev