Clay (short for “C Layout”) is a high-performance 2D UI layout library in C, offering a declarative, Flexbox-like layout model with microsecond performance. It features a single-header design, zero dependencies, and support for WebAssembly, making it lightweight yet powerful for responsive UI rendering. The Clay macro by default accepts an ID as its first argument, which is usually provided by the CLAY_ID() convenience macro. Elements can also be created with auto-generated IDs, by using the CLAY_AUTO_ID() macro. Element IDs have two main use cases. Firstly, tagging an element with an ID allows you to query information about the element later, such as its mouseover state or dimensions. Secondly, IDs are visually useful when attempting to read and modify UI code, as well as when using the built-in debug tools.
Features
- Microsecond-level layout performance
- Flexbox-style declarative layout with text wrapping, scrolling, and scaling
- Single-file (~4k LOC) header-only design, no external dependencies
- WebAssembly support—compact (~15 KB uncompressed) builds for browser use
- Static arena memory (no malloc/free), low memory overhead even for large layouts
- Renderer-agnostic: emits rendering primitives usable in any engine or HTML output