Clay is a 2D UI layout engine in C with a flex-box-like model, declarative element macros, and microsecond-scale layout times. It emits renderer-agnostic primitives for games, native apps, WASM in the browser, or HTML.
Overview
Clay (C Layout) targets developers who need responsive interface layout without tying themselves to one graphics stack. It uses nested declarative macros in C that mirror familiar UI hierarchy patterns while remaining ordinary C code with loops and conditionals.
The layout model supports text wrapping, scroll containers, aspect-ratio scaling, floating overlays, and pointer-driven scrolling. A transition API can animate layout and style properties. Layout results arrive as a sorted list of render commands (rectangles, text, images) that any engine or an HTML backend can consume.
The implementation ships as a single header with no external dependencies and static arena memory without malloc. It can compile to a small WASM bundle for browser use. Official examples include Raylib, WebGL canvas, and an HTML renderer; the project site itself is laid out with Clay.
Built-in inspector-style debug tooling overlays hierarchy and configuration. Bindings and ports exist for languages beyond C, listed in the project documentation.
Key features
- Microsecond layout performance
- Flex-box-like responsive model
- Single header, zero dependencies
- WASM build for browsers
- Static arena memory, no malloc
- Transition API for animations
- Renderer-agnostic render commands
- Built-in layout debug inspector
Use cases
- Custom game engine UI layout
- Browser UIs via WASM
- Retained-mode rendering integration
- Immediate-mode UI redraw each frame