ccompose
ccompose is a C11 wrapper around Clay that adds declarative blocks inspired by Jetpack Compose to Clay's immediate-mode layout engine. It includes an optional raylib rendering backend.
#include "ccompose.h"
int main(void) {
CC_SetWindow(960, 640, "Hello");
CC_Init();
while (CC_Running()) {
CC_Begin();
Column("Root",
.layout = { .sizing = { Grow(), Grow() },
.padding = PadAll(24),
.childAlignment = { .x = AlignXCenter(),
.y = AlignYCenter() } },
.backgroundColor = Color(18, 18, 20, 255)) {
Text("Hello, ccompose!",
.textColor = Color(255, 255, 255, 255),
.fontSize = 32);
}
CC_End();
}
CC_Shutdown();
return 0;
}
ccompose is at
v0.1.5. Its macros, lifecycle helpers, and build layout may change between 0.x releases. Pin the tag or commit you depend on.
Key ideas
- Every container macro (
Column,Row,Box,Button) opens a Clay element. Fields map directly toClay_ElementDeclaration.Buttonalso lowers its background alpha while hovered or pressed. - Containers use a single-iteration
forloop, soColumn(...) { ... }compiles as C11. - The raylib backend is enabled by default. Use
-DCCOMPOSE_BACKEND_RAYLIB=OFFfor headless builds, CI, and tests. - Clay owns the layout arena. ccompose adds no allocations after
CC_Init().
Navigation
Getting started
- Getting started: build, run the demo, first program
- Building: per-platform builds, cross-compiling, headless, CMake options, using ccompose in your project
- Web (WASM): Emscripten build,
CC_RUN_LOOP, link flags, assets - Lifecycle:
CC_Init, the frame loop, fonts, window configuration - Architecture: how ccompose, Clay, and raylib fit together
Building UI
- Containers:
Column,Row,Box,Elementand the control-flow rules - Text: the
Textmacro, font loading, global color, wrap & alignment - Images:
Image,CC_ImageRef, scale modes, rounded corners, texture loading - Layout: sizing (
Fit/Grow/Fixed/Percent), padding, child gap, alignment - Spacer and divider: auto-id flexible spacers and rule lines
- Progress:
LinearProgressandCircularProgress, with a value or animated - Styling: background, corner radius, borders, shadows, aspect ratio
- Interaction:
Buttonwith default hover and press feedback,CC_Hovered,CC_Clicked - Floating: tooltips, modals, anchored overlays
- Scroll and clip:
CC_Scroll, drag + wheel input,.clipviewports - Custom drawing: escape hatch for arbitrary raylib draw calls inside the layout
- Transitions:
DefineTransition, slide/fade presets, easing functions
Reference
- API reference: every public macro, function, type and constant, one page per area, each with an example
- raylib integration: mixing raw raylib calls with ccompose
- Headless mode:
CCOMPOSE_NO_BACKEND, CI & test patterns - Troubleshooting: common build & runtime mistakes
Minimum viable program
This program opens a window and draws text with raylib's default font:
CC_SetWindow(800, 600, "hi");
CC_Init();
while (CC_Running()) {
CC_Begin();
Column("Root",
.layout = { .sizing = { Grow(), Grow() },
.childAlignment = { .x = AlignXCenter(),
.y = AlignYCenter() } }) {
Text("hi", .textColor = Color(255,255,255,255), .fontSize = 48);
}
CC_End();
}
CC_Shutdown();
See Getting started for the CMake commands and Building for platform notes.