Add a fast, dependency-free layout engine to a native desktop game UI written in C or C++.
Compile the layout logic to WebAssembly and use it inside a browser-based tool.
Build an embedded device UI where no heap allocations at runtime is a hard requirement.
Prototype a scrollable, wrapping panel layout in C without pulling in a full UI framework.
Single header file with no dependencies, but you must provide a static memory arena and a custom renderer.
Clay, short for C Layout, is a high-performance library for building two-dimensional user interface layouts in the C programming language. A UI layout library is the piece of code that figures out where on the screen each button, panel, image and piece of text should sit, and how those positions should change when the window resizes or content wraps. Clay handles that calculation and aims to do it in microseconds. Under the hood, Clay uses a flex-box-like layout model, similar in spirit to how websites arrange elements, with support for text wrapping, scrolling containers, aspect-ratio scaling and a transition API for animating layouts. You describe a UI in C using nested macros that look a bit like a React component tree, and Clay produces a sorted list of rendering primitives such as rectangles and text. Clay does not draw anything itself, it is renderer-agnostic, so you take that list and hand it to whichever renderer you already have, whether that is a 2D engine, a 3D engine, or even HTML. The whole library is one header file of around 4,800 lines with no dependencies at all, not even the C standard library, and it manages memory through a static arena that you provide, with no calls to malloc or free at runtime. It can also be compiled with clang to a 15 KB WebAssembly file that runs in the browser. You would actually use Clay if you are building a native desktop, game or embedded UI in C or C++ and want a layout engine that is fast, predictable, and free of hidden allocations. The full README is longer than what was provided.
← nicbarker on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.