Hex1b 0.176.0

Hex1b

Hex1b is a .NET library for building TUI apps using an approachable code-first API.

NuGet License: MIT

Installation

dotnet add package Hex1b

Quick Start

Hello World

A minimal application that displays text and a quit button:

using Hex1b;

await using var terminal = Hex1bTerminal.CreateBuilder().WithHex1bApp(ctx =>
    ctx.VStack(b => [
        b.Text("Hello, Terminal!"),
        b.Button("Quit").OnClick(e => e.Context.RequestStop())
    ])
).Build();

await terminal.RunAsync();

Counter with State

An interactive counter demonstrating mutable state across renders:

using Hex1b;

// State persists outside the builder function
var count = 0;

await using var terminal = Hex1bTerminal.CreateBuilder().WithHex1bApp(ctx =>
    ctx.VStack(b => [
        b.Text($"Count: {count}"),
        b.Button("Increment").OnClick(_ => count++),
        b.Button("Decrement").OnClick(_ => count--),
        b.Text(""),
        b.Button("Quit").OnClick(e => e.Context.RequestStop())
    ])
).Build();

await terminal.RunAsync();

Counter with Custom Key Bindings

A counter controlled with custom keyboard shortcuts (Ctrl+A to increment, Ctrl+D to decrement):

using Hex1b;
using Hex1b.Input;

var count = 0;

await using var terminal = Hex1bTerminal.CreateBuilder().WithHex1bApp(ctx =>
    ctx.VStack(b => [
        b.Text($"Count: {count}"),
        b.Text(""),
        b.Text("Ctrl+A: Increment"),
        b.Text("Ctrl+D: Decrement"),
        b.Text("Ctrl+Q: Quit")
    ]).InputBindings(bindings =>
    {
        bindings.Ctrl().Key(Hex1bKey.A).Action(() => count++, "Increment counter");
        bindings.Ctrl().Key(Hex1bKey.D).Action(() => count--, "Decrement counter");
        bindings.Ctrl().Key(Hex1bKey.Q).Action(ctx => ctx.RequestStop(), "Quit");
    })
).Build();

await terminal.RunAsync();

Layout System

Hex1b uses a constraint-based layout system with size hints:

// Vertical stack with flexible sizing
new VStackWidget(
    children: [contentWidget, statusBarWidget],
    sizeHints: [SizeHint.Fill, SizeHint.Content]
);

Size Hints:

  • SizeHint.Fill – Expand to fill available space
  • SizeHint.Content – Size to fit content
  • SizeHint.Fixed(n) – Fixed size of n units
  • SizeHint.Weighted(n) – Proportional sizing with weight n

Widgets

Widget Description
TextBlockWidget Display static or dynamic text
TextBoxWidget Editable text input with cursor and selection
ButtonWidget Clickable button with label and action
ListWidget Scrollable list with selection support
VStackWidget Vertical layout container
HStackWidget Horizontal layout container
SplitterWidget Resizable split pane layout
BorderWidget Container with border and optional title
ScrollPanelWidget Scrollable content area

Input Bindings

Define keyboard shortcuts using the fluent builder API:

widget.InputBindings(bindings =>
{
    // Simple key
    bindings.Key(Hex1bKey.Delete).Action(() => DeleteItem());
    
    // Modifier keys (any combination)
    bindings.Ctrl().Key(Hex1bKey.S).Action(() => Save(), "Save");
    bindings.Shift().Key(Hex1bKey.Tab).Action(() => FocusPrevious(), "Previous");
    bindings.Ctrl().Shift().Key(Hex1bKey.S).Action(() => SaveAs(), "Save as");
    
    // Multi-step chords
    bindings.Ctrl().Key(Hex1bKey.K)
        .Then().Key(Hex1bKey.C)
        .Action(() => CommentLine(), "Comment line");
});

Theming

Apply built-in themes or create your own:

using Hex1b.Theming;

await using var terminal = Hex1bTerminal.CreateBuilder()
    .WithHex1bApp(options => options.Theme = Hex1bThemes.Sunset, builder)
    .Build();
await terminal.RunAsync();

Construction and Native AOT

Construct applications through Hex1bTerminal; Hex1bApp constructors are internal. The terminal owns the app lifetime. Use the WithHex1bApp options callback for app configuration and its app-instance callback when you need Invalidate() or RequestStop() outside widget event handlers.

CreateBuilder() keeps the normal interactive console defaults. CreateSlimBuilder() registers neither presentation nor workload; explicitly configure both. For headless Native AOT applications:

await using var terminal = Hex1bTerminal.CreateSlimBuilder()
    .WithHeadless()
    .WithHex1bApp(ctx => ctx.Text("Hello"))
    .Build();
await terminal.RunAsync();

Calling WithHeadless() on the normal builder replaces its presentation at runtime but can retain console code in a Native AOT binary. The slim entry point avoids registering that console factory in the first place.

Documentation

License

Hex1b is licensed under the MIT License.

Showing the top 20 packages that depend on Hex1b.

Packages Downloads
Aspire.Hosting
Core abstractions for the Aspire application model.
14
Aspire.Hosting
Core abstractions for the Aspire application model.
13
Aspire.Hosting.Redis
Redis® support for Aspire.
12
Aspire.Hosting
Core abstractions for the Aspire application model.
12
Aspire.Hosting.Redis
Redis® support for Aspire.
11
Aspire.Hosting
Core abstractions for the Aspire application model.
11
Aspire.Hosting
Core abstractions for the Aspire application model.
5
Aspire.Hosting.Redis
Redis® support for Aspire.
4
Aspire.Hosting.Redis
Redis® support for Aspire.
3
Aspire.Hosting
Core abstractions for the Aspire application model.
3

Version Downloads Last updated
0.177.0-beta.2143.1.8314fbc 1 11/29/2026
0.176.0 1 11/29/2026
0.176.0-beta.2071.1.1976946 2 11/21/2026
0.175.0 9 10/20/2026
0.175.0-alpha.1963.1.e84f086 2 10/14/2026
0.175.0-alpha.1905.1.34394d2 3 10/14/2026
0.175.0-alpha.1898.1.9dc034e 3 10/14/2026
0.174.0 5 10/13/2026
0.174.0-beta.1899.1.9dc034e 7 10/14/2026
0.174.0-alpha.1835.1.1856406 9 10/14/2026
0.173.0 6 10/10/2026
0.173.0-alpha.1824.1.98d8766 4 10/13/2026
0.173.0-alpha.1801.1.3dc2d9b 4 10/05/2026
0.172.0 5 10/02/2026
0.172.0-beta.1788.1.f01b043 5 10/05/2026
0.172.0-alpha.1787.1.f01b043 10 09/30/2026
0.172.0-alpha.1785.1.d253961 4 10/13/2026
0.172.0-alpha.1654.1.f826137 3 10/13/2026
0.172.0-alpha.1652.1.6a01c54 10 10/12/2026
0.172.0-alpha.1650.1.2df4512 5 09/30/2026
0.171.0 4 09/30/2026
0.170.0 9 09/30/2026
0.170.0-alpha.1620.1.85e091a 5 09/30/2026
0.170.0-alpha.1616.1.6221fe4 5 09/30/2026
0.169.1 3 09/30/2026
0.169.1-beta.1619.1.ce890db 2 10/12/2026
0.169.0 4 10/02/2026
0.169.0-beta.1611.1.c1a7c2d 4 09/30/2026
0.169.0-alpha.1608.1.d6a20d4 6 10/07/2026
0.169.0-alpha.1597.1.365795a 5 09/30/2026
0.168.0 12 10/02/2026
0.168.0-beta.1592.1.d87cce1 7 10/11/2026
0.168.0-alpha.1588.1.cb3cf27 4 10/05/2026
0.168.0-alpha.1585.1.1de7974 5 10/03/2026
0.168.0-alpha.1583.1.f78698d 10 10/03/2026
0.168.0-alpha.1579.1.1561964 6 10/10/2026
0.168.0-alpha.1573.1.2917e83 5 10/06/2026
0.168.0-alpha.1571.1.18731da 10 09/30/2026
0.167.1-beta.1570.1.7675a6d 8 10/05/2026
0.167.0 3 10/02/2026
0.167.0-beta.1566.1.6eea363 4 10/07/2026
0.167.0-alpha.1565.1.6eea363 4 09/30/2026
0.167.0-alpha.1564.1.ebc298d 8 10/12/2026
0.167.0-alpha.1561.1.093b67b 3 09/30/2026
0.167.0-alpha.1559.1.448450d 4 10/03/2026
0.167.0-alpha.1551.1.34adbdd 11 10/02/2026
0.167.0-alpha.1549.1.496ccf5 5 10/05/2026
0.167.0-alpha.1547.1.798b26c 7 10/03/2026
0.167.0-alpha.1538.1.991370f 9 10/03/2026
0.167.0-alpha.1536.1.6b20787 7 09/30/2026
0.167.0-alpha.1534.1.2783ae7 4 09/30/2026
0.167.0-alpha.1528.1.50cc76e 12 10/05/2026
0.167.0-alpha.1522.1.3085d8b 4 10/03/2026
0.167.0-alpha.1519.1.b8be265 4 10/05/2026
0.167.0-alpha.1517.1.81d1e3d 10 09/30/2026
0.167.0-alpha.1512.1.d6b2173 6 09/30/2026
0.167.0-alpha.1509.1.1f47fd9 12 10/03/2026
0.167.0-alpha.1465.1.d8af16a 5 10/05/2026
0.167.0-alpha.1414.1.b68865c 3 10/02/2026
0.166.1-beta.1558.1.5e98f7f 7 10/10/2026
0.166.0 8 09/30/2026
0.166.0-beta.1554.1.4652df1 5 09/30/2026
0.166.0-beta.1424.1.6566aac 5 10/07/2026
0.166.0-beta.1420.1.25aa164 8 10/05/2026
0.166.0-beta.1416.1.1e1d57b 4 10/07/2026
0.166.0-beta.1412.1.815f257 4 09/30/2026
0.166.0-alpha.1366.1.3ea400e 5 10/04/2026
0.166.0-alpha.1361.1.468c1e6 5 10/10/2026
0.165.0 7 10/02/2026
0.165.0-beta.1343.1.39947cb 4 09/30/2026
0.165.0-alpha.1337.1.4f44be7 6 10/05/2026
0.165.0-alpha.1331.1.b11d534 12 10/12/2026
0.165.0-alpha.1325.1.e6f8a29 6 10/03/2026
0.165.0-alpha.1322.1.62b3bb3 4 09/30/2026
0.165.0-alpha.1316.1.5401318 9 10/10/2026
0.165.0-alpha.1314.1.33573c1 3 10/12/2026
0.164.2-beta.1321.1.7522404 5 10/02/2026
0.164.1 4 09/30/2026
0.164.0 6 10/02/2026
0.164.0-beta.1308.1.3837d3a 4 10/05/2026
0.164.0-alpha.1304.1.ddc2032 3 10/10/2026
0.163.0 2 09/30/2026
0.162.0 5 10/02/2026
0.161.0 4 09/30/2026
0.160.0 3 09/30/2026
0.159.0 4 10/02/2026
0.158.0 11 10/02/2026
0.157.0 13 10/02/2026
0.156.0 4 10/02/2026
0.155.0 12 09/30/2026
0.154.0 8 10/02/2026
0.153.0 4 09/30/2026
0.152.0 5 10/02/2026
0.151.0 3 09/30/2026
0.150.0 3 09/30/2026
0.149.0 6 10/02/2026
0.148.0 12 10/02/2026
0.147.0 4 10/02/2026
0.146.0 12 10/02/2026
0.145.0 7 10/02/2026
0.144.0 9 09/30/2026
0.143.0 4 09/30/2026
0.142.0 8 10/02/2026
0.141.0 5 09/30/2026
0.140.0 8 09/30/2026
0.139.0 10 09/30/2026
0.138.0 3 09/30/2026
0.137.0 6 09/30/2026
0.136.0 7 09/30/2026
0.135.0 7 09/30/2026
0.134.0 5 09/30/2026
0.133.0 5 09/30/2026
0.132.0 12 09/30/2026
0.131.0 7 09/30/2026
0.130.0 17 09/30/2026
0.129.0 3 10/02/2026
0.128.0 9 10/02/2026
0.127.0 5 10/02/2026
0.126.0 7 10/02/2026
0.125.0 5 10/02/2026
0.124.0 4 10/02/2026
0.123.0 4 09/30/2026
0.122.0 4 09/30/2026
0.121.0 8 09/30/2026
0.120.0 18 09/30/2026
0.119.0 5 09/30/2026
0.118.0 12 09/30/2026
0.117.0 3 09/30/2026
0.116.0 9 09/30/2026
0.115.0 3 09/30/2026
0.114.0 3 09/30/2026
0.113.0 4 09/30/2026
0.112.0 11 09/30/2026
0.111.0 4 10/05/2026
0.110.0 5 09/30/2026
0.109.0 5 09/30/2026
0.108.0 8 09/30/2026
0.107.0 4 09/30/2026
0.106.0 6 09/30/2026
0.105.0 8 09/30/2026
0.104.0 6 09/30/2026
0.103.0 4 09/30/2026
0.102.0 11 09/30/2026
0.101.0 5 09/30/2026
0.100.0 4 09/30/2026
0.99.0 10 10/04/2026
0.98.0 10 10/08/2026
0.97.0 5 10/08/2026
0.96.0 4 10/08/2026
0.95.0 7 10/08/2026
0.94.0 7 10/08/2026
0.93.0 5 10/04/2026
0.92.0 4 10/08/2026
0.91.0 11 10/04/2026
0.90.0 4 10/04/2026
0.89.0 5 10/08/2026
0.88.0 11 10/04/2026
0.87.0 11 10/12/2026
0.86.0 4 10/08/2026
0.85.0 6 10/08/2026
0.84.0 3 10/08/2026
0.83.0 5 10/04/2026
0.82.0 11 10/08/2026
0.81.0 7 10/04/2026
0.80.0 5 10/04/2026
0.79.0 5 10/08/2026
0.78.0 2 10/08/2026
0.77.0 5 10/04/2026
0.76.0 4 10/08/2026
0.75.0 5 10/08/2026
0.74.0 4 10/08/2026
0.73.0 4 10/04/2026
0.72.0 12 10/08/2026
0.71.0 5 10/04/2026
0.70.0 4 10/04/2026
0.69.0 6 10/08/2026
0.68.0 4 10/08/2026
0.67.0 4 10/08/2026
0.66.0 4 10/04/2026
0.65.0 6 10/08/2026
0.64.0 4 10/08/2026
0.63.0 7 10/04/2026
0.62.0 4 10/08/2026
0.61.0 11 10/04/2026
0.60.0 5 10/04/2026
0.59.0 4 10/12/2026
0.58.0 10 10/08/2026
0.57.0 4 10/08/2026
0.56.0 2 10/08/2026
0.55.0 13 10/04/2026
0.54.0 4 10/08/2026
0.53.0 5 10/04/2026
0.52.0 8 10/08/2026
0.51.0 5 10/04/2026
0.50.0 4 10/04/2026
0.49.0 8 10/08/2026
0.48.0 4 10/08/2026
0.47.0 5 10/08/2026
0.46.0 3 10/08/2026
0.45.0 12 10/08/2026
0.44.0 4 10/04/2026
0.43.0 4 10/04/2026
0.42.0 4 10/08/2026
0.41.0 5 10/04/2026
0.40.0 13 10/04/2026
0.39.0 5 10/04/2026
0.38.0 5 10/04/2026
0.37.0 6 10/04/2026
0.36.0 10 10/04/2026
0.35.0 5 10/04/2026
0.34.0 4 10/04/2026
0.33.0 4 10/04/2026
0.32.0 7 10/04/2026
0.31.0 7 10/04/2026
0.30.0 4 10/04/2026
0.29.0 10 10/08/2026
0.28.0 4 10/08/2026
0.27.0 5 10/08/2026
0.26.0 3 10/08/2026
0.25.0 4 10/08/2026
0.24.0 5 10/08/2026
0.23.0 5 10/04/2026
0.22.0 9 10/04/2026
0.21.0 11 10/04/2026
0.20.0 5 10/02/2026
0.19.0 5 10/04/2026
0.18.0 4 10/04/2026
0.17.0 4 10/04/2026
0.16.0 5 10/04/2026
0.15.0 4 10/04/2026
0.14.0 4 10/04/2026
0.13.0 11 10/04/2026
0.12.0 5 10/04/2026
0.11.0 5 09/30/2026
0.10.0 4 09/30/2026
0.9.0 5 09/30/2026
0.8.0 10 09/30/2026
0.7.0 5 09/30/2026
0.6.0 12 09/30/2026
0.5.0 5 09/30/2026
0.4.0 5 09/30/2026
0.3.0 4 09/30/2026
0.2.0 4 09/30/2026
0.1.0 3 09/30/2026