Installation & Build Setup
tui.zig requires Zig 0.17.0+ (zig version). No system C libraries or external native toolchains are required.
Method 1: Stable Version Pinning (Recommended)
Pin the v0.1.0 tagged release archive for reproducible builds:
sh
zig fetch --save https://github.com/muhammad-fiaz/tui.zig/archive/refs/tags/0.1.0.tar.gzMethod 2: Main Branch Install
Track the latest commits on the main branch:
sh
zig fetch --save git+https://github.com/muhammad-fiaz/tui.zig.git#mainOr declare either dependency explicitly inside build.zig.zon:
zig
.dependencies = .{
.tui = .{
.url = "https://github.com/muhammad-fiaz/tui.zig/archive/refs/tags/0.1.0.tar.gz",
.hash = "...", // Generated by `zig fetch --save`
},
},3. Wire Module in build.zig
zig
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const tui_dep = b.dependency("tui", .{
.target = target,
.optimize = optimize,
});
const exe = b.addExecutable(.{
.name = "my-tui-app",
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "tui", .module = tui_dep.module("tui") },
},
}),
});
b.installArtifact(exe);
}4. Repository Build Targets
Inside the tui.zig repository itself:
| Command | Purpose |
|---|---|
zig build | Build the static library archive |
zig build test | Run all library and widget unit/integration tests |
zig build examples | Compile all 34 example binaries |
zig build run-all-examples | Execute every example in non-interactive --headless mode |
zig build run-<name> | Run any specific interactive example (e.g. zig build run-custom-ui) |
zig build docs | Emit Zig HTML API documentation into zig-out/docs/ |
zig build -Dtarget=x86_64-linux-gnu | Cross-compile for 64-bit Linux |
zig build -Dtarget=x86-windows | Cross-compile for 32-bit Windows |
zig build -Dtarget=aarch64-macos | Cross-compile for Apple Silicon macOS |