Clay is a minimalist yet powerful 2D UI layout library distributed as a single C header file that brings flexbox-style layout capabilities to performance-critical applications. The library processes layout calculations in microseconds using a custom algorithm that handles complex responsive layouts including text wrapping, scrolling containers, aspect ratio scaling, and nested flex containers without any dynamic memory allocation or external dependencies.
The design philosophy centers on zero-overhead abstraction: Clay uses static arena-based memory management that preallocates a fixed buffer and performs no heap allocation during layout computation. This makes it deterministic and suitable for embedded systems, game engines, and real-time applications where memory fragmentation and allocation latency are unacceptable. The API uses C macros to build UI hierarchies declaratively with modular configuration of layout properties, colors, borders, and corner radii.
Clay has rapidly gained attention in the systems programming community with over 17,000 GitHub stars since its release, appealing to developers building custom renderers and UI frameworks. The library is renderer-agnostic, outputting a sorted array of drawing primitives that can be composited with OpenGL, Vulkan, SDL, Raylib, or any graphics backend. A WebAssembly build enables browser-based usage, and the official website itself is built and rendered entirely using Clay as a demonstration of its capabilities.