Lay out panels and buttons in a custom C or C++ game tool without pulling in a UI framework
Add draggable splitters between panels in an existing immediate-mode UI
Compose fixed, percentage, and auto-sized children with grow and shrink overflow handling
Embed Flexbox-style layout in a memory-constrained app with no runtime allocations
No text rendering or scrolling, so you must pair it with your own renderer and input loop.
Bento is a small C library for arranging boxes on a screen using the Flexbox layout idea borrowed from web browsers. Flexbox is a way of describing how rectangles stack and resize next to each other, growing or shrinking to fit the space available. The whole library lives in one header file written in C99, which means a developer drops a single file into their project to get layout behavior for buttons, panels, and other rectangular UI parts. The author cites Nic Barker's Clay library as the main inspiration but lists clear differences. What Bento does not try to do is spelled out plainly. There is no text rendering, no animation system, and no scrolling containers. It does not allocate memory at runtime, so a maximum element count is set at compile time. What it does add on top of the Clay model is grow and shrink weights for handling under and overflow, plus resizing splitters that the user can drag with a mouse to change the size of neighbouring panels. The layout works as a tree of elements. Each element has a position and a size that the library computes when you call bt_compute_layout. Elements can be sized in three ways: automatic (wrapping their children), fixed in pixels, or as a percentage of the parent. When children together ask for less space than the parent has, the leftover is shared among elements that have a grow weight. When they ask for more, the excess is taken from elements that have a shrink weight. Optional min and max clamps cap the result. To use Bento, the developer declares a static array of element nodes, builds the tree once with nested begin and end calls, and then calls the compute function every frame to refresh positions. Splitter helpers handle mouse drags and report whether a splitter is blocked when both neighbours have hit their size limits.
Generated 2026-05-22 · Model: sonnet-4-6 · Verify against the repo before relying on details.