Hello there. I had just learnt the fundamentals of zig, and wanna cook some project to test my capabilities. However, I couldn’t find a suitable GUI library, capy targets 0.14, native is more typescript-oriented.
What’s your choice of doing gui
Hello there. I had just learnt the fundamentals of zig, and wanna cook some project to test my capabilities. However, I couldn’t find a suitable GUI library, capy targets 0.14, native is more typescript-oriented.
What’s your choice of doing gui
Hello, if you want game i would go with Raylib, for general GUI then something like DVUI is popular.
Overall you can also use almost any C library.
Robert ![]()
Here’s a minimal sokol-zig + Dear ImGui example to get started (needs a very recent Zig nightly - unfortunately I just noticed that the latest Zig nightly broke it again via the translate-c dependency
- it’s a bit of a whack-a-mole game in the last few months unfortunately, apparently ArrayList.getLast() has been removed).
I’m an irrational Dear ImGui fanboy because it’s so frigging awesome to work with and is the best thing since sliced bread in general, but be aware that it’s mostly useful for UI tools, not ‘consumer apps’ (e.g. one unsolved problem is ‘accessibility’).
(still, people do ‘real apps’ with Dear ImGui, e.g. here you can browse through the ‘showcase galleries’:
In Go I would use the embed package to bundle HTML, CSS, and JS into a binary. Then I would start the binary, which would start an HTTP server, which would serve the embedded files, to serve the UI.
Is something like this possible to do in Zig?
You can use @embedFile to bundle things into the binary. You could definitely use that with the web server in std to serve the embedded files.
Personally I wrote a GUI library for my project and used Sokol as just a graphics backend. The idea for that particular library was that the entire GUI layout must be known at comptime.
Not sure if that was the wrong / right choice, but just wanted to share this to mention that DIY is also an option
thx let me try dvui out
I have settled with dvui these days since it is the closest solution to imgui with mostly pure zig and c implementation which it much easier to maintain and troubleshoot, while it recently have the tab group update.
Besides, despite not sure about the status of the project, the zig binding of clay is also pretty interesting since it cover most of the commonly used elements with minimal components (basically just box and text elements playing with different style.)
You can also check out knots (shameless self-ad) if you are looking for a pure Zig library (only non-Zig dependency is wgpu-native if using the webgpu backend targeting native). But it is obviously not as mature as DVUI so keep that in mind ![]()
Interesting explanation about immediate mode vs retained mode
I implemented bindings for Slint, so you could use it in Zig.
I’ve personally moved to DVUI since then. ![]()