1
0
Fork
You've already forked knots
0
forked from shahwali/knots
High performance immediate-mode GUI rendering library.
  • Zig 95.9%
  • WGSL 2.1%
  • GLSL 1.5%
  • C 0.5%
2026年06月26日 17:48:30 -04:00
examples Move to Vulkan v1.3 2026年06月18日 23:08:11 +02:00
src more updates for 0.17 2026年06月26日 17:48:30 -04:00
tests/snapshots Add GPU rendering qoi snapshot tests 2026年06月21日 23:00:19 +02:00
.gitignore init 2026年04月16日 13:32:36 +02:00
build.zig more updates for 0.17 2026年06月26日 17:48:30 -04:00
build.zig.zon Merge branch 'shahwali-main' 2026年06月26日 15:36:19 -04:00
LICENSE.md init 2026年04月16日 13:32:36 +02:00
README.md Select GPU backends at compile time and improve UI accessibility ( #13 ) 2026年06月17日 22:46:07 +02:00

Knots

Knots is a high performance cross-platform immediate-mode GUI library written in Zig.

Requirements

  • Zig compiler, minimum version can be found in build.zig.zon. I try to keep up with the master branch.
  • If using the Vulkan backend, glslc must be installed and accessible on the system. This is due to the shaders used in the Vulkan backend being compiled as part of building knots.
  • On Linux, Wayland development packages are required: wayland-client, wayland-cursor, wayland-protocols, wayland-scanner, pkg-config, and xkbcommon.

Install

zig fetch --save git+https://codeberg.org/shahwali/knots.git

Minimal app

// build.zigconstGPUBackend=@import("knots").GPUBackend;constknots=b.dependency("knots",.{.target=target,.optimize=optimize,.gpu_backend=GPUBackend.vulkan});exe.root_module.addImport(knots.module("knots"));// ormod.addImport(knots.module("knots"));
conststd=@import("std");constknots=@import("knots");pubfnmain(init:std.process.Init)!void{varapp=tryknots.App.init(init.io,init.gpa,.{.window=.{.width=1280,.height=720,.title="Playground",},});deferapp.deinit();tryapp.start(frameCb);}fnframeCb(app:*knots.App)!void{constsize=app.window.getSize();returnapp.e(.{knots.component.Rect{.width=.fixed(@floatFromInt(size.width)),.height=.fixed(@floatFromInt(size.height)),.padding=.init(16,16,16,16),.dir=.column,.key=.src(@src()),},});}

Supported platforms:

Platform Supported GPU APIs
macOS WebGPU and Vulkan (MoltenVK)
Linux WebGPU and Vulkan
Windows WebGPU and Vulkan
Web (emscripten) WebGPU

Distributing Vulkan applications on macOS

Knots checks for a bundled Vulkan loader before falling back to the system loader. A standalone application bundle using the Vulkan backend must include the loader, MoltenVK, and its ICD manifest:

MyApp.app/Contents/Frameworks/libvulkan.1.dylib
MyApp.app/Contents/Frameworks/libMoltenVK.dylib
MyApp.app/Contents/Resources/vulkan/icd.d/MoltenVK_icd.json

The manifest's library_path must resolve to the bundled libMoltenVK.dylib.

Examples

See examples, you can also try the web version of the playground here.

Goals

Below goals are listed in order of importance.

  1. Provide a way to build highly performant cross-platform desktop applications.
  2. UI code should get out of the way, letting the developer spend more time on actual problems.
  3. Minimal lean builds, fast compile times.
  4. Highly configurable, with sane defaults.

Known limitations

  • Linux windowing is Wayland-only.
  • Text rendering is UTF-8/codepoint based. HarfBuzz shaping, bidi layout, ligatures, font fallback, and IME composition are not implemented yet.