git404hub

what is clay fr?

nicbarker/clay — explained in plain English

Analysis updated 2026-06-24

17,210CAudience · developerComplexity · 3/5Setup · moderate

tl;dr

Single-header C library that calculates UI layouts using a flexbox-like model and outputs a renderer-agnostic list of drawing commands, no dependencies, no malloc at runtime, compiles to 15 KB WebAssembly.

vibe map

mindmap
  root((Clay))
    What it does
      Layout calculation
      Flex-box model
      Renderer agnostic
    Features
      Text wrapping
      Scrolling containers
      Aspect ratio scaling
      Transition API
    Tech stack
      C single header
      WebAssembly
      No dependencies
    Use cases
      Desktop UI
      Game engines
      Embedded UI

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

what do people make with this?

VIBE 1

Add a fast, dependency-free layout engine to a native desktop game UI written in C or C++.

VIBE 2

Compile the layout logic to WebAssembly and use it inside a browser-based tool.

VIBE 3

Build an embedded device UI where no heap allocations at runtime is a hard requirement.

VIBE 4

Prototype a scrollable, wrapping panel layout in C without pulling in a full UI framework.

what's the stack?

CWebAssemblyclang

how it stacks up fr

nicbarker/claybkaradzic/bgfxuberguidoz/flipper
Stars17,21017,02916,998
LanguageCCC
Setup difficultymoderatehardmoderate
Complexity3/54/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

how do i run it?

Difficulty · moderate time til it works · 30min

Single header file with no dependencies, but you must provide a static memory arena and a custom renderer.

License not mentioned in the explanation.

in plain english

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.

prompts (copy fr)

prompt 1
Using the Clay layout library in C, show me how to define a scrollable list of items with text wrapping and hand the result to a custom renderer.
prompt 2
How do I set up Clay's memory arena and initialize the library from scratch in a C project?
prompt 3
Write a Clay UI definition with a row of buttons and an image panel, then show how to iterate the output render commands.
prompt 4
Show me how to compile Clay to WebAssembly with clang and render the output in a browser canvas.
prompt 5
How do I use Clay's transition API to animate a panel expanding from collapsed to full width?

Frequently asked questions

what is clay fr?

Single-header C library that calculates UI layouts using a flexbox-like model and outputs a renderer-agnostic list of drawing commands, no dependencies, no malloc at runtime, compiles to 15 KB WebAssembly.

What language is clay written in?

Mainly C. The stack also includes C, WebAssembly, clang.

What license does clay use?

License not mentioned in the explanation.

How hard is clay to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is clay for?

Mainly developer.

peek the repo → explain another one

This repo across BitVibe Labs

double-check against the repo, no cap.