ConsoleForge 0.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package ConsoleForge --version 0.0.2
                    
NuGet\Install-Package ConsoleForge -Version 0.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ConsoleForge" Version="0.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ConsoleForge" Version="0.0.2" />
                    
Directory.Packages.props
<PackageReference Include="ConsoleForge" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ConsoleForge --version 0.0.2
                    
#r "nuget: ConsoleForge, 0.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ConsoleForge@0.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ConsoleForge&version=0.0.2
                    
Install as a Cake Addin
#tool nuget:?package=ConsoleForge&version=0.0.2
                    
Install as a Cake Tool

ConsoleForge

A C# 12 / .NET 8 terminal UI framework. Simple to use, expressive enough for real apps.

Architecture: Elm-loop — immutable model, pure Update, pure View. No mutable state in widgets.
Renderer: Double-buffered, cell-level diff. Only changed cells hit the terminal per frame.
Docs: popplywop.github.io/ConsoleForge


Quick Start

using ConsoleForge.Core;
using ConsoleForge.Layout;
using ConsoleForge.Styling;
using ConsoleForge.Widgets;

record HelloModel(string Message) : IModel
{
    public ICmd? Init() => null;

    public (IModel Model, ICmd? Cmd) Update(IMsg msg) => msg switch
    {
        KeyMsg { Key: ConsoleKey.Q } => (this, Cmd.Quit()),
        _ => (this, null)
    };

    public IWidget View() =>
        new BorderBox(
            title: "ConsoleForge",
            body: new TextBlock(Message),
            style: Style.Default.BorderForeground(Colors.Green)
        );
}

Program.Run(new HelloModel("Press Q to quit."));
dotnet run

Core Concepts

The Elm Loop

IModel.Init() → optional startup command
     ↓
  input event → IModel.Update(msg) → (newModel, cmd?)
                                           ↓
                                     IModel.View() → IWidget tree → render

Your model is an immutable record. Update returns a new copy. View is pure — no side effects.

Widgets

Widget Description
TextBlock Renders text, word-wraps at region width
Container Lays out children along horizontal or vertical axis
BorderBox Bordered box with optional title and body widget
List Scrollable list, keyboard navigable, dispatches selection messages
TextInput Single-line text input with cursor, dispatches change messages

Layout

Children declare Width and Height as SizeConstraint:

SizeConstraint.Fixed(24)    // exact column/row count
SizeConstraint.Flex(1)      // proportional share of remaining space
SizeConstraint.Auto         // shrink to content
SizeConstraint.Min(n, inner)
SizeConstraint.Max(n, inner)

Container does two-pass layout: fixed children first, then flex children share the remainder.

Styling

Style is an immutable value type. All methods return a new Style — fluent builder pattern:

var style = Style.Default
    .Foreground(Colors.Cyan)
    .Bold()
    .Padding(1, 2)
    .Border(Borders.Rounded);

Styles inherit from parent theme when properties are unset — no redundant overrides needed.

Commands

ICmd represents async side effects returned alongside the new model:

Cmd.Quit()                        // exit the program
Cmd.From(async ct => someMsg)     // run async work, dispatch result as message
Cmd.Batch(cmd1, cmd2)             // run multiple commands

Focus

IFocusable widgets (TextInput, List) receive keyboard events when focused.
FocusManager.CycleNext / CyclePrev traverse focusable widgets in render order.


Samples

Sample Description
ConsoleForge.TodoApp Todo list — browse, add, toggle, delete
ConsoleForge.Gallery Widget showcase — all widgets, styles, layouts
ConsoleForge.SysMonitor Live system stats via async commands

Run a sample:

dotnet run --project samples/ConsoleForge.TodoApp

Project Structure

src/
  ConsoleForge/
    Core/         IModel, IMsg, ICmd, Program (runtime loop), Renderer, FocusManager
    Layout/       IWidget, Container layout engine, RenderContext (double-buffer), Region
    Styling/      Style, Theme, BorderSpec, Colors, ColorProfile
    Terminal/     ITerminal, AnsiTerminal, Termios (Unix raw mode)
    Widgets/      TextBlock, TextInput, List, BorderBox, Container
tests/
  ConsoleForge.Tests/       Unit + integration tests, VirtualTerminal test double
  ConsoleForge.Benchmarks/  BenchmarkDotNet render benchmarks
samples/
  ConsoleForge.Gallery/
  ConsoleForge.SysMonitor/
  ConsoleForge.TodoApp/

Building

dotnet build
dotnet test

Requires .NET 8 SDK. No external NuGet dependencies beyond System.Reactive.


License

MIT — see LICENSE.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.3.0 108 4/21/2026
0.2.2 98 4/20/2026
0.2.1 114 4/17/2026
0.2.0 107 4/16/2026
0.1.0 110 4/14/2026
0.0.2 108 4/14/2026