https://github.com/skyleite/luyoga
Lua bindings to facebook/yoga
https://github.com/skyleite/luyoga
css layout-engine love2d lua ui yoga
Last synced: 6 months ago
JSON representation
Lua bindings to facebook/yoga
- Host: GitHub
- URL: https://github.com/skyleite/luyoga
- Owner: SkyLeite
- Created: 2025-08-05T18:17:04.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-08-05T19:03:18.000Z (6 months ago)
- Last Synced: 2025-08-05T20:27:47.326Z (6 months ago)
- Topics: css, layout-engine, love2d, lua, ui, yoga
- Language: Lua
- Homepage: https://skyleite.github.io/luyoga/
- Size: 104 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Luyoga
This is a set of Lua-friendly bindings for [Yoga](https://www.yogalayout.dev), Facebook's layout library.
## Setup
Simply copy the `luyoga` directory to your project and require it.
## Usage
The library is designed to resemble Yoga as closely as possible, so the official docs should be enough to learn how to use it.
### Building a Yoga tree
```lua
local yoga = require("yoga")
local root = yoga.Node.new()
root.style:setFlexDirection(yoga.Enums.FlexDirection.Row)
root.style:setWidth(100)
root.style:setHeight(100)
local child0 = yoga.Node.new()
child0.style:setFlexGrow(1)
child0.style:setMargin(1, yoga.Enums.Edge.Right)
root:insertChild(child0, 0)
local child1 = yoga.Node.new()
child1.style:setFlexGrow(1)
root:insertChild(child1, 1)
```
### Laying out the tree
```lua
root:caculateLayout(nil, nil, yoga.Enums.Direction.LTR)
```
### Reading layout results
```lua
local left = child0.layout:getLeft();
local height = child0.layout:getHeight();
```
## Contributing
### Running locally
1. Build the project locally using `luarocks make --tree=./dev --no-manifest luyoga-1.0-1.rockspec`
2. Update `test.lua` with your code and run it with `luajit test.lua`
### Writing tests
TODO