nicbarker/clay
FreeHigh performance UI layout library in C.
About nicbarker/clay
Clay (short for C Layout) is a high performance 2D UI layout library written in C. It provides a flex-box-like layout model for building complex, responsive user interfaces with support for text wrapping, scrolling containers, and aspect ratio scaling. Clay features a single-file header (clay.h) with zero dependencies, microsecond layout performance, and a static arena-based memory system that avoids malloc/free. It includes a declarative, React-like syntax, a transition API for animations, and is renderer agnostic: it outputs a sorted list of rendering primitives that can be composited in any 3D engine or compiled to HTML. Clay can be compiled to WebAssembly (15kb uncompressed) for browser use. The library is open source under the MIT license.
Key Features
Pros & Cons
- Extremely high performance with microsecond layout times
- Zero runtime dependencies, single header file
- Suitable for resource-constrained environments (no malloc, low memory overhead)
- Renderer agnostic, works with any graphics engine or HTML
- Declarative, functional API inspired by modern frameworks
- Supports responsive design with flex-box model
- Built-in transition API for smooth animations
- Open source with permissive MIT license
- Limited to 2D UI layout; no built-in rendering or window management
- Requires C/C++ development and manual integration with a renderer
- Documentation and examples are primarily in the GitHub repository
- Not an AI tool (though it can be used to build AI tool GUIs)