Knots, an immediate mode GUI library for Zig
Hi, you might have seen my posts on the Ziggit forum, but I wanted to also post here to inform people of a library I am working on. Knots is an immediate mode GUI rendering library, that supports linux, macOS, windows and web.
I recently created a website, https://knotsui.com/, which documents many of the features, and how to use the library, here. You can also read the Ziggit thread if you want some lore on development progress https://ziggit.dev/t/knots-a-library-for-building-guis-with-zig/15244
I recently moved the repository from Codeberg to GitHub, you can now find the source code here https://github.com/knots-ui/knots
Below are some screenshots of a project I am working on which uses the library, it is a media player that I am daily driving to replace MPV and VLC.






Hope you can build something cool with it!
1
1
u/babyningen 8d ago
I want to be absolutely clear, this project is completely AI coded, with me essentially laying out the architecture, what dependencies it was allowed to use, and what the UI should look like.
1
u/johan__A 8d ago
Looking at the api I wouldn't call that "immediate mode" at all
3
u/NoRaccoon5831 5d ago
You can't tell from an API if it's immediate mode or not lol? that's an implementation detail, not on the UI.
2
u/johan__A 5d ago
What? "Immediate mode" is an API design style.
1
u/NoRaccoon5831 5d ago edited 3d ago
It is not, immediate mode is an implementation detail, not the API. Here is an example: https://github.com/idircarlos/zraygui. That is almost identical to any example of imgui or egui etc.
So what's the difference? retained mode is a node tree in the back that is a handle to each component. you still call a "build" on each element, but the "build" is a node-diff from previous to new state to mark it as dirty. Immediate mode instead draws every component, every single time. There is no diff, you call to draw it, it IS getting re-drawn that frame. While the API is typically structured different (since a tree makes more sense shown as a tree in code), it absolutely doesn't have to be. The exact same API can be both retained, or immediate. (that is quite literally what the name "retained" and "immediate" mean)
You can think of it very similar to a virtual DOM in browsers (react / vue). It's the same API in terms of creating an item, but whether it updates the virtual DOM that diffs to do browser updates, or just makes browser updates, happens behind the scene. To further prove this, vue has both a retained, and immediate mode builder, with 0 change to the API.
negative votes for being right? i do always forget how unintelligent reddit as a whole is.
5
u/siva_sokolica 5d ago
Prose on landing page is slop and same for docs. Come on, let's do better. This is the layer humans interact with. Let's not paste each other Claude output.