Repository navigation
API Reference
rizuki edited this page Nov 30, 2026
·
4 revisions
Look up public macros, functions, types, and constants from ccompose.h by purpose. Each row links to examples. Names marked raylib only are unavailable in headless builds (-DCCOMPOSE_BACKEND_RAYLIB=OFF).
Names starting with CC__ (two underscores) or ending in _, such as CC_BOX_IMPL_, support macro expansion. Treat them as internal.
- Lifecycle and window
- Fonts
- Containers
- Text
- Images
- Spacers and dividers
- Progress indicators
- Shadow
- Custom drawing
- Interaction
- Scroll and clip
- Floating
- Sizing, padding and alignment sugar
- Color, border and radius sugar
- Transitions
- Element ids and strings
- Type aliases
- Enum value aliases
- Compile-time constants
| Name | Signature | What it does | Page |
|---|---|---|---|
CC_SetWindow |
void (int width, int height, const char *title) |
Window size and title. Call before CC_Init. |
Lifecycle |
CC_SetWindowFlags |
void (unsigned int raylib_flags) |
raylib FLAG_* bits (resizable, MSAA, vsync). Call before CC_Init. |
Lifecycle |
CC_SetBackground |
void (CC_Color color) |
Clear color used at the start of every frame. | Lifecycle |
CC_SetErrorHandler |
void (void (*handler)(CC_ErrorData)) |
Replace the default Clay error printer. Call before CC_Init. |
Lifecycle |
CC_Init |
void (void) |
Open the window, set up the Clay arena and fonts, register CC_Shutdown with atexit. |
Lifecycle |
CC_Shutdown |
void (void) |
Unload fonts, close the window, free the arena. Safe to call twice. | Lifecycle |
CC_Running |
bool (void) |
Main-loop condition. False once the window is closed or the exit key is pressed. Always true headless. | Lifecycle |
CC_Begin |
void (void) |
Start a frame: read input, reset per-frame pools, begin the Clay layout. | Lifecycle |
CC_End |
CC_RenderCommandArray (void) |
Finish the layout, draw it, present. Returns the render commands. | Lifecycle |
CC_RUN_LOOP |
CC_RUN_LOOP(frame_fn) |
Portable main loop: a while natively, emscripten_set_main_loop on the web. |
Web (WASM) |
CC_SetViewport |
void (float width, float height) |
Layout size for headless runs. No effect with raylib, which reads the window size every frame. | Headless mode |
| Name | Signature | What it does | Page |
|---|---|---|---|
CC_LoadFont |
int (const char *path, int base_size) |
Load a font file into a new slot (up to 15). Returns its id, or -1 on failure. Call after CC_Init. |
Lifecycle |
CC_InitFont |
int (int fontId, int base_size) |
Make a loaded font the global default for Text, and optionally set the default size. |
Lifecycle |
CC_GetGlobalFontId |
int (void) |
Current default font id. | Lifecycle |
CC_GetGlobalFontSize |
int (void) |
Current default font size. Starts at CC_DEFAULT_FONT_SIZE. |
Lifecycle |
CC_SetGlobalFontColor |
int (CC_Color color) |
Default text color for Text, dividers and progress indicators. |
Lifecycle |
CC_GetGlobalFontColor |
CC_Color (void) |
Current default text color. | Lifecycle |
All containers take a string-literal id first ("" for anonymous), then any CC_ElementDeclaration fields, then a { ... } block of children.
| Name | Form | What it does | Page |
|---|---|---|---|
Column |
Column("id", .field = ...) { } |
Children flow top to bottom. | Containers |
Row |
Row("id", .field = ...) { } |
Children flow left to right. | Containers |
Box |
Box("id", .field = ...) { } |
Z-stack: the first child sets the size, later children are layered on top. | Containers |
Element |
Element(direction, "id", .field = ...) { } |
Generic container with a direction chosen at runtime (CC_LEFT_TO_RIGHT or CC_TOP_TO_BOTTOM). |
Containers |
Button |
Button("id", .field = ...) { } |
A Row that dims its background while hovered (×0.85) and pressed (×0.70). |
Interaction |
CC_OpenElement |
CC_Scope (CC_String id, CC_LayoutDirection dir, CC_ElementDeclaration decl) |
Runtime hook behind Column, Row and Element. |
Architecture |
CC_OpenBox |
CC_Scope (CC_String id, CC_ElementDeclaration decl) |
Runtime hook behind Box. |
Containers |
CC_OpenButton |
CC_Scope (CC_String id, CC_ElementDeclaration decl) |
Runtime hook behind Button. |
Interaction |
CC_CloseScope |
void (CC_Scope *scope) |
Closes an element opened by one of the hooks above. Idempotent. | Architecture |
CC_Scope |
struct { int active; } |
Loop-guard state the container macros create. | Architecture |
| Name | Form | What it does | Page |
|---|---|---|---|
Text |
Text(const char *str, .field = ...) |
Text leaf. Fields are CC_TextElementConfig: .fontId, .fontSize, .textColor, .letterSpacing, .lineHeight, .wrapMode, .textAlignment. Unset font, size and color fall back to the globals. |
Text |
CC_DEFAULT_FONT_SIZE |
16 |
Starting global font size. | Text |
raylib only, except CC_ImageScale.
| Name | Form | What it does | Page |
|---|---|---|---|
Image |
Image("id", CC_ImageRef *ref, .field = ...) |
Image leaf drawn into the element's box. | Images |
ImgFill |
CC_ImageRef *ImgFill(Texture2D *tex) |
Stretch to fill the box, ignoring aspect ratio. | Images |
ImgFit |
CC_ImageRef *ImgFit(Texture2D *tex) |
Fit inside the box, keeping aspect ratio (letterboxed). | Images |
ImgCrop |
CC_ImageRef *ImgCrop(Texture2D *tex) |
Cover the box, keeping aspect ratio, cropping overflow. | Images |
CC_AcquireImageRef |
CC_ImageRef *(Texture2D *tex, CC_ImageScale scale) |
The pool call behind ImgFill / ImgFit / ImgCrop. Returns NULL when the 128-entry per-frame pool is full. |
Images |
CC_ImageRef |
struct { Texture2D *texture; CC_ImageScale scale; } |
What Image draws. |
Images |
CC_ImageScale |
CC_IMAGE_FILL, CC_IMAGE_FIT, CC_IMAGE_CROP
|
Scale modes. | Images |
CC_LoadImage |
Texture2D (const char *path) |
Load an image file as a texture. Call after CC_Init. |
Images |
CC_UnloadImage |
void (Texture2D texture) |
Free a texture from CC_LoadImage. Call before CC_Shutdown. |
Images |
Leaves with no id and no block. Safe to use in loops.
| Name | Form | What it does | Page |
|---|---|---|---|
HSpacer |
HSpacer() |
Grows along the width. Pushes siblings apart in a Row. |
Spacer and divider |
VSpacer |
VSpacer() |
Grows along the height. Pushes siblings apart in a Column. |
Spacer and divider |
Spacer |
Spacer(.width = ..., .height = ...) |
Spacer with explicit sizing per axis. Unset axes are Fit(). Fields: CC_SpacerOpts. |
Spacer and divider |
HDivider |
HDivider(.length, .thickness, .color) |
Horizontal rule. length 0 grows, thickness defaults to 1, color to the global font color. Fields: CC_DividerOpts. |
Spacer and divider |
VDivider |
VDivider(.length, .thickness, .color) |
Vertical rule. Same fields as HDivider. |
Spacer and divider |
CC_HSpacer, CC_VSpacer, CC_Spacer, CC_HDivider, CC_VDivider
|
functions | What the macros above call. |
| Name | Form | What it does | Page |
|---|---|---|---|
LinearProgress |
LinearProgress(float value, .sizing, .color, .trackColor) |
Pill-shaped bar. value is 0 to 1, or CC_PROGRESS_INFINITE. Default size { Grow(), Fixed(4) }. Works headless. |
Progress |
CircularProgress |
CircularProgress(float value, .sizing, .thickness, .color, .trackColor) |
Ring that fills clockwise from 12 o'clock. Default size 40×40, stroke 4. Draws nothing headless. | Progress |
CC_PROGRESS_INFINITE |
-1.0f |
Pass as value for an animated, indeterminate indicator. |
Progress |
CC_LinearProgressOpts, CC_CircularProgressOpts
|
structs | Field structs for the two macros. | Progress |
CC_LinearProgress, CC_CircularProgress
|
functions | What the macros call. | |
TextInput |
TextInput(const char *id, CC_TextEdit *edit, .sizing, .padding, .background, .border, .borderFocused, .textColor, .placeholderColor, .caretColor, .selectionColor, .cornerRadius, .fontId, .fontSize, .placeholder) |
Single-line text field, returns a CC_TextInputEvent bitmask. |
Text input |
CC_TextEdit, CC_TextEditSet, CC_TextEditApply
|
struct, functions | Editing state of a field and the pure edit operations. | Text input |
CC_TextInputFocused, CC_TextInputBlur
|
functions | Query or drop keyboard focus. | Text input |
| Name | Form | What it does | Page |
|---|---|---|---|
Shadow |
.custom = Shadow(.offset, .blur, .spread, .color) |
Drop shadow behind an element, following its .cornerRadius. Default color Color(0,0,0,64). Can't share an element with a Draw callback. |
Styling |
CC_ShadowOpts |
struct { CC_Vector2 offset; float blur; float spread; CC_Color color; } |
Fields for Shadow. |
Styling |
CC_Shadow |
CC_CustomElementConfig (CC_ShadowOpts opts) |
What Shadow calls. |
|
CC_ShadowSlot, CC_SHADOW_TAG, CC_SHADOW_POOL_SIZE
|
Pool entry, its render tag (-2), and pool size (128 per frame). For custom renderers. |
Styling |
| Name | Form | What it does | Page |
|---|---|---|---|
Draw |
Draw("id", CC_DrawFn fn, void *user, .field = ...) { } |
A Column whose final bounding box is passed to your callback, so you can draw into it with raylib. |
Custom drawing |
DrawRow |
DrawRow("id", fn, user, ...) { } |
Same, with children flowing left to right. | Custom drawing |
DrawColumn |
DrawColumn("id", fn, user, ...) { } |
Same as Draw. |
Custom drawing |
CC_DrawFn |
void (*)(CC_BoundingBox bb, void *user) |
Callback type. bb is in screen pixels. |
Custom drawing |
CC_AcquireDrawSlot |
CC_DrawSlot *(CC_DrawFn fn, void *user) |
Pool call behind the macros. Use it to attach a callback to Element or another container. Returns NULL when the 128-entry pool is full. |
Custom drawing |
CC_DrawSlot |
struct | Pool entry. Don't fill it yourself. | Custom drawing |
| Name | Form | What it does | Page |
|---|---|---|---|
CC_Hovered |
bool CC_Hovered("id") |
True while the pointer is over the element. Uses the previous frame's layout. | Interaction |
CC_Clicked |
bool CC_Clicked("id") |
True on the one frame the left button goes down over the element. Always false headless. | Interaction |
CC_PointerOver |
bool (CC_ElementId id) |
Clay's hit test, for ids built with CC_IDI or CC_SID. |
Interaction |
CC_ElementDataOf |
CC_ElementData CC_ElementDataOf("id") |
The element's bounding box from the last finished layout, and .found. Same id rules as CC_Hovered. |
Interaction |
CC_GetElementData |
CC_ElementData (CC_ElementId id) |
Same, for ids built with CC_IDI or CC_SID. |
Interaction |
CC_BUTTON_HOVER_ALPHA |
0.85f |
Background alpha multiplier while a Button is hovered. Override with -D or a #define before the include. |
Interaction |
CC_BUTTON_PRESS_ALPHA |
0.70f |
Same, while pressed. | Interaction |
| Name | Form | What it does | Page |
|---|---|---|---|
CC_ScrollUpdate |
CC_ScrollUpdate(CC_Scroll *s, "id", .horizontal, .vertical, .wheel, .drag, .wheelSpeed, .noClamp) |
Drive a scroll offset from wheel and drag input, clamped to the content. Call before the element. No-op headless. | Scroll and clip |
CC_Scroll |
struct { CC_Vector2 offset; bool dragging; } |
Your persistent scroll state. Feed offset into .clip. |
Scroll and clip |
CC_ScrollConfig |
struct | Fields for CC_ScrollUpdate. wheelSpeed defaults to 40 px. |
Scroll and clip |
ClipX |
.clip = ClipX(CC_Vector2 offset) |
Clip and scroll horizontally. | Scroll and clip |
ClipY |
.clip = ClipY(offset) |
Clip and scroll vertically. | Scroll and clip |
ClipXY |
.clip = ClipXY(offset) |
Both axes. | Scroll and clip |
| Name | Form | What it does | Page |
|---|---|---|---|
FloatOnParent |
.floating = FloatOnParent(z) |
Float over the parent at z-index z. |
Floating |
FloatOnRoot |
.floating = FloatOnRoot(z) |
Float over the whole window at z-index z. |
Floating |
CC_ATTACH_TO_* |
NONE, PARENT, ELEMENT_WITH_ID, ROOT
|
Values for .floating.attachTo. |
Floating |
CC_ATTACH_POINT_* |
LEFT_TOP … RIGHT_BOTTOM (9 values) |
Values for .floating.attachPoints.element and .parent. |
Floating |
| Name | Form | What it does | Page |
|---|---|---|---|
Fit |
Fit() |
Shrink to the children. The default. | Layout |
Grow |
Grow() |
Take the remaining space, shared with sibling Grow()s. |
Layout |
Fixed |
Fixed(n) |
Exactly n pixels. |
Layout |
Percent |
Percent(p) |
Fraction of the parent, p from 0.0 to 1.0. |
Layout |
GrowMinMax |
GrowMinMax(min, max) |
Grow() bounded to [min, max] pixels. max 0 is unbounded. |
Layout |
FitMinMax |
FitMinMax(min, max) |
Fit() bounded to [min, max] pixels. max 0 is unbounded. |
Layout |
SizingAll |
.sizing = SizingAll(Grow()) |
Same sizing on both axes. | Layout |
SizingOnly |
.sizing = SizingOnly(.width = Fixed(200)) |
Set one axis by name. The other is Fit(). |
Layout |
PadAll |
PadAll(n) |
n on every side. |
Layout |
PadSymmetric |
PadSymmetric(h, v) |
h left and right, v top and bottom. |
Layout |
PadOnly |
PadOnly(.left = 8, .top = 4) |
Per side. Unset sides are 0. | Layout |
AlignXStart, AlignXCenter, AlignXEnd
|
.childAlignment.x = AlignXCenter() |
Horizontal child alignment. | Layout |
AlignYStart, AlignYCenter, AlignYEnd
|
.childAlignment.y = AlignYCenter() |
Vertical child alignment. | Layout |
ChildAlign |
.childAlignment = ChildAlign(.x = ..., .y = ...) |
Both axes in one expression. | Layout |
| Name | Form | What it does | Page |
|---|---|---|---|
Color |
Color(r, g, b, a) |
Color from 0 to 255 channels. | Styling |
ColorHex |
ColorHex(0xRRGGBB) |
Opaque color from a hex literal. | Styling |
ColorHexA |
ColorHexA(0xRRGGBBAA) |
Color with alpha from a hex literal. | Styling |
BorderAll |
BorderAll(n) |
n px on every side. |
Styling |
BorderSymmetric |
BorderSymmetric(h, v) |
h left and right, v top and bottom. |
Styling |
BorderOnly |
BorderOnly(.left = 1, .betweenChildren = 1) |
Per side, plus dividers between children. | Styling |
RadiusAll |
RadiusAll(n) |
Every corner. A large value makes a pill. | Styling |
RadiusTopBottom |
RadiusTopBottom(t, b) |
Top corners t, bottom corners b. |
Styling |
RadiusLeftRight |
RadiusLeftRight(l, r) |
Left corners l, right corners r. |
Styling |
RadiusOnly |
RadiusOnly(.topLeft = 8) |
Per corner. Unset corners are 0. | Styling |
| Name | Form | What it does | Page |
|---|---|---|---|
DefineTransition |
DefineTransition(name, seconds, .enter = {...}, .exit = {...}, .handler, .properties, .interactionHandling) |
Declare a transition at file scope. Use it as .transition = name(). |
Transitions |
CC_TransitionEffect |
struct | One side of a transition: .slideX, .slideY, .fade, .backgroundColor, .overlayColor, .borderColor, .borderWidth, .enterTrigger, .exitTrigger, .siblingOrdering. |
Transitions |
CC_EaseOut |
bool (CC_TransitionArgs) |
Default easing. | Transitions |
CC_Linear, CC_EaseIn, CC_EaseInOut
|
bool (CC_TransitionArgs) |
Other built-in easings. | Transitions |
CC_TRANSITION_PROPERTY_* |
bit flags | What to animate, when setting .properties by hand. |
Transitions |
CC_TRANSITION_STATE_* |
IDLE, ENTERING, TRANSITIONING, EXITING
|
Transition state values. | Transitions |
CC_TRANSITION_ENTER_* |
SKIP_ON_FIRST_PARENT_FRAME (default), TRIGGER_ON_FIRST_PARENT_FRAME
|
Values for .enterTrigger. |
Transitions |
CC_TRANSITION_EXIT_* |
SKIP_WHEN_PARENT_EXITS (default), TRIGGER_WHEN_PARENT_EXITS
|
Values for .exitTrigger. |
Transitions |
CC_EXIT_TRANSITION_ORDERING_* |
UNDERNEATH_SIBLINGS (default), NATURAL_ORDER, ABOVE_SIBLINGS
|
Values for .siblingOrdering. |
Transitions |
CC_TRANSITION_*_INTERACTIONS_WHILE_TRANSITIONING_POSITION |
DISABLE_, ALLOW_
|
Values for .interactionHandling. |
Transitions |
| Name | Form | What it does | Page |
|---|---|---|---|
CC_IDI |
CC_ElementId CC_IDI("label", index) |
Id from a literal plus an index, for rows in a loop. | Containers |
CC_SID |
CC_ElementId CC_SID(CC_String s) |
Id from a runtime string. | Containers |
CLAY_ID |
CC_ElementId CLAY_ID("label") |
Clay's id from a literal. Use .id for .floating.parentId. |
Floating |
CC_StrIntern |
CC_String (const char *s) |
Copy a runtime string into permanent storage, so it stays valid after your buffer is reused. | Architecture |
Each is a #define onto the Clay type, so the two spellings are interchangeable.
| ccompose | Clay | Used for |
|---|---|---|
CC_ElementDeclaration, CC_Decl
|
Clay_ElementDeclaration |
Every container's fields |
CC_LayoutConfig |
Clay_LayoutConfig |
.layout |
CC_LayoutDirection |
Clay_LayoutDirection |
.layout.layoutDirection, Element
|
CC_Sizing, CC_SizingAxis, CC_SizingType
|
Clay_Sizing, Clay_SizingAxis, Clay__SizingType
|
.layout.sizing |
CC_Padding |
Clay_Padding |
.layout.padding |
CC_ChildAlignment, CC_LayoutAlignmentX, CC_LayoutAlignmentY
|
Clay_ChildAlignment, … |
.layout.childAlignment |
CC_CornerRadius |
Clay_CornerRadius |
.cornerRadius |
CC_BorderElementConfig, CC_BorderWidth
|
Clay_BorderElementConfig, Clay_BorderWidth
|
.border |
CC_TextElementConfig, CC_TextStyle
|
Clay_TextElementConfig |
Text fields |
CC_TextElementConfigWrapMode, CC_TextAlignment
|
Clay_TextElementConfigWrapMode, Clay_TextAlignment
|
.wrapMode, .textAlignment
|
CC_ImageElementConfig |
Clay_ImageElementConfig |
.image |
CC_FloatingElementConfig, CC_FloatingAttachToElement
|
Clay_FloatingElementConfig, … |
.floating |
CC_ClipElementConfig |
Clay_ClipElementConfig |
.clip |
CC_AspectRatioElementConfig |
Clay_AspectRatioElementConfig |
.aspectRatio |
CC_CustomElementConfig |
Clay_CustomElementConfig |
.custom |
CC_TransitionElementConfig, CC_TransitionData, CC_TransitionArgs, CC_TransitionProperty, CC_TransitionState, CC_TransitionEnterTrigger, CC_TransitionExitTrigger, CC_TransitionInteraction, CC_ExitTransitionOrdering
|
Clay_Transition… |
.transition and easing callbacks |
CC_Color |
Clay_Color |
{r, g, b, a} floats, 0 to 255 |
CC_String |
Clay_String |
{length, chars} |
CC_Dimensions |
Clay_Dimensions |
{width, height} |
CC_Vector2 |
Clay_Vector2 |
{x, y} |
CC_BoundingBox |
Clay_BoundingBox |
{x, y, width, height}, passed to CC_DrawFn
|
CC_ElementId |
Clay_ElementId |
Hashed element id |
CC_ErrorData |
Clay_ErrorData |
Error handler argument |
CC_ElementData |
Clay_ElementData |
{boundingBox, found}, from CC_ElementDataOf
|
CC_PointerCaptureMode |
Clay_PointerCaptureMode |
.floating.pointerCaptureMode |
CC_RenderCommand, CC_RenderCommandArray
|
Clay_RenderCommand, Clay_RenderCommandArray
|
What CC_End returns |
CC_RenderCommandArray_Get |
Clay_RenderCommandArray_Get |
Index into the array |
| ccompose | Field |
|---|---|
CC_LEFT_TO_RIGHT, CC_TOP_TO_BOTTOM
|
.layout.layoutDirection, first argument of Element
|
CC_SIZING_TYPE_FIT, CC_SIZING_TYPE_GROW, CC_SIZING_TYPE_PERCENT, CC_SIZING_TYPE_FIXED
|
CC_SizingAxis.type, when inspecting sizing. Prefer Fit() and friends when writing it. |
CC_ALIGN_X_LEFT, CC_ALIGN_X_CENTER, CC_ALIGN_X_RIGHT
|
.childAlignment.x. Same as AlignXStart() / AlignXCenter() / AlignXEnd(). |
CC_ALIGN_Y_TOP, CC_ALIGN_Y_CENTER, CC_ALIGN_Y_BOTTOM
|
.childAlignment.y. Same as AlignYStart() / AlignYCenter() / AlignYEnd(). |
CC_TEXT_WRAP_WORDS (default), CC_TEXT_WRAP_NEWLINES, CC_TEXT_WRAP_NONE
|
Text .wrapMode (Text) |
CC_TEXT_ALIGN_LEFT (default), CC_TEXT_ALIGN_CENTER, CC_TEXT_ALIGN_RIGHT
|
Text .textAlignment (Text) |
CC_ATTACH_TO_*, CC_ATTACH_POINT_*
|
.floating (Floating) |
CC_POINTER_CAPTURE_MODE_CAPTURE (default), CC_POINTER_CAPTURE_MODE_PASSTHROUGH
|
.floating.pointerCaptureMode. Passthrough lets clicks reach what is under a floating element. |
CC_RENDER_COMMAND_TYPE_CUSTOM |
CC_RenderCommand.commandType for Draw, Shadow and CircularProgress output |
CC_TRANSITION_*, CC_EXIT_TRANSITION_ORDERING_*
|
See Transitions above |
| Name | Value | Meaning |
|---|---|---|
CC_DEFAULT_FONT_SIZE |
16 |
Starting global font size |
CC_PROGRESS_INFINITE |
-1.0f |
Indeterminate progress value |
CC_BUTTON_HOVER_ALPHA |
0.85f |
Overridable, see Interaction |
CC_BUTTON_PRESS_ALPHA |
0.70f |
Overridable |
CC_SHADOW_TAG |
-2 |
Render tag on Shadow custom data |
CC_SHADOW_POOL_SIZE |
128 |
Shadows per frame |
CCOMPOSE_NO_BACKEND |
defined in headless builds | Test with #ifdef to guard raylib-only code. Set by the CMake target, don't define it yourself. |