Introduction
Nuklear is a single-header ANSI C GUI library that uses an immediate-mode paradigm to draw user interfaces. It has no dependencies, no default rendering backend, and no platform-specific code, making it ideal for embedding in games, tools, embedded systems, and any C or C++ project that needs a lightweight UI without pulling in a heavy framework.
What Nuklear Does
- Provides a complete widget set (buttons, sliders, text input, trees, tabs, groups) in one C header file
- Uses immediate-mode rendering: UI is declared every frame, no persistent widget objects to manage
- Outputs abstract draw commands that you feed to any rendering backend (OpenGL, Vulkan, DirectX, SDL, etc.)
- Compiles on any platform with an ANSI C89 compiler, including embedded targets
- Supports custom memory allocators, UTF-8 text, and user-defined widget skinning
Architecture Overview
Nuklear operates as a stateless command buffer generator. Each frame, application code calls Nuklear functions to describe the UI layout and widgets. Nuklear processes input, calculates layout, and emits a list of draw commands (rectangles, triangles, text, images) into a command buffer. A platform-specific backend then iterates this buffer and submits the actual draw calls. This separation means Nuklear itself has zero platform or graphics API dependencies.
Self-Hosting & Configuration
- Copy
nuklear.hinto your project; defineNK_IMPLEMENTATIONin exactly one translation unit - Choose a rendering backend from the
demo/directory (SDL, GLFW, X11, GDI, Allegro, SFML, etc.) or write your own - Configure font rendering by loading a TTF font with the built-in font baker or supply your own font atlas
- Control memory allocation by passing custom
nk_allocatorstructs for heap-free or pool-based allocation - Adjust styling through the
nk_stylestruct: colors, padding, rounding, and spacing are fully configurable
Key Features
- Single-header library: one file to include, no build system integration needed
- Pure ANSI C89 with no dependencies — compiles with GCC, Clang, MSVC, and embedded toolchains
- Built-in layout engine with row-based, space-based, and custom layout modes
- Font baking utility for TTF fonts with configurable glyph ranges and atlas packing
- Permissive dual-licensed under MIT and Public Domain
Comparison with Similar Tools
- Dear ImGui — C++ immediate-mode GUI; Nuklear is pure C89 and single-header, better for C projects and embedded targets
- Raygui — Immediate-mode GUI for raylib; Nuklear is renderer-agnostic and works with any graphics backend
- egui — Rust immediate-mode GUI; Nuklear targets the C/C++ ecosystem
- Microui — Even smaller immediate-mode library; Nuklear offers a richer widget set and built-in font baking
- GTK/Qt — Retained-mode heavyweight frameworks; Nuklear is orders of magnitude smaller with no runtime dependencies
FAQ
Q: How do I render Nuklear output? A: Nuklear produces abstract draw commands. You write a small backend (or use an included demo backend) that translates these commands into your graphics API's draw calls.
Q: Is Nuklear suitable for game engine editor UIs? A: Yes. Its immediate-mode design and renderer independence make it popular for game engine tooling and in-game debug overlays.
Q: Can I use Nuklear from languages other than C? A: Community bindings exist for Python, Go, Rust, Lua, and others, though the primary API is C.
Q: Does Nuklear handle high-DPI displays? A: You control scaling by adjusting font size and the global scale factor. The library does not auto-detect DPI, giving you full control.