added react like componets example

This commit is contained in:
2026-01-16 16:58:36 +13:00
parent 6ff9c3050d
commit 6d5aafb78d

View File

@@ -115,6 +115,46 @@ and finally free the arena with a retained_capacity as the ui will more then lik
_ = al.reset(.retain_capacity);
```
## react like componets:
you can also create react like componets by creating functions blocks that return a Node, please note that this function is inlined, this is required as children from this node will be shared between all compoents that use this node.
```zig
inline fn button() UI.Node {
return UI.ElementWborder(
.{
.bottom = 2,
.left = 2,
.right = 2,
.top = 2,
},
.{
.b = 30,
},
.{
.name = "button",
.rect = .{
.h = 20,
.w = 60,
},
.on_click = .{
.func = &updateButton,
.data = &.{},
},
.on_hover = .{
.func = &hoverButton,
.data = &.{},
},
.style = .{
.background_colour = .{
.g = 255,
},
.rounded = 25,
},
},
);
}
```
## adding shoots to your project
fetch the repo