Declarative & reactive
Describe what the UI should look like; yui reconciles the rest. A Store change re-renders one component in a tree of thousands — the rest is untouched.
A React-like component model with reactive state and selective re-rendering — built on the Yoga layout engine. If you know React, Flutter, or SwiftUI, you'll feel at home.
#include <yui/yui.hpp>
using namespace yui;
Store<int> count(0);
VNode Counter() {
int n = count.use();
return Column(
Text("Count: " + std::to_string(n))
.fontSize(24).color(0xFFFFFFFF),
Box(Text("+"))
.padding(12)
.backgroundColor(0xFF3366FF)
.borderRadius(6)
.onClick([] {
count.set([](int& n) { n++; });
})
)
.gap(16)
.alignItems(AlignItems::Center);
} Component model, selective re-rendering, and Yoga layout — the parts of React and Flutter that make UI code tractable, without leaving native.
Describe what the UI should look like; yui reconciles the rest. A Store change re-renders one component in a tree of thousands — the rest is untouched.
Powered by Facebook's Yoga engine. If you know CSS flexbox — row, column, gap, flexGrow, justifyContent — you already know yui layout.
useState, useRef, useEffect, useField. Local state, lifecycle effects, and two-way Store binding — the patterns you reach for, in C++20.
.padding(8).backgroundColor(0x1a1a1aFF).borderRadius(4).onClick(...). Layout, styling, and events compose into readable trees.
A fiber tree tracks identity, hook state, and subscriptions; a flat render tree drives layout and hit-testing. Selective re-rendering, preserved state.
Ship with SDL2 or NanoVG, or write your own renderer against the render tree. Custom drawing via the Canvas primitive when you need raw graphics.
Add yui to your CMake project, or clone and run an example.
include(FetchContent)
FetchContent_Declare(
yui
GIT_REPOSITORY https://github.com/dustinlacewell/yoga-ui.git
GIT_TAG master
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(yui)
target_link_libraries(your_app PRIVATE yui::yui) FetchContent pulls yui and its Yoga / NanoVG submodules automatically.
git clone --recursive https://github.com/dustinlacewell/yoga-ui.git
cd yoga-ui
cmake -B build
cmake --build build --target hello_world
./build/bin/hello_world
The --recursive flag pulls the layout-engine submodule. Requires
a C++20 compiler and CMake 3.16+.