Zig Libui NG

I made some bindings for libui-ng to make it easier to use from zig:

Libui is a c library for creating cross-platform GUIs using each platforms native GUI toolkit. Development on the original library ceased a few years ago, unfortunately, but work has continued in the libui-ng fork.

The work depends on an open pull request I have to add a build.zig to libui-ng itself.

It’s still a work in progress but quite usable for making basic GUIs. Here’s the example from the README:

const std = @import("std");
const ui = @import("ui");

pub fn on_closing(_: *ui.Window, _: ?*void) ui.Window.ClosingAction {
    return .should_close;

pub fn main() !void {
    var init_data = ui.InitData{
        .options = .{ .Size = 0 },
    ui.Init(&init_data) catch {
        std.debug.print("Error initializing LibUI: {s}\n", .{init_data.get_error()});
    defer ui.Uninit();

    const main_window = try ui.Window.New("Hello, World!", 320, 240, .hide_menubar);

    main_window.OnClosing(void, on_closing, null);

    main_window.MsgBox("Message Box", "Hello, World!");


Some reasons you might consider using this over directly using libui-ng:

  • Proper namespacing of functions
  • Booleans are made to use zig’s bool type instead of c_int
  • Table(T) comptime function to reduce boilerplate when using the Table control