Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/Nabeel20/Badar

๐ŸŒ• Declarative, retained* and flexbox inspired UI library for Lรถve2D
https://github.com/Nabeel20/Badar

gui love2d lua

Last synced: about 2 months ago
JSON representation

๐ŸŒ• Declarative, retained* and flexbox inspired UI library for Lรถve2D

Lists

README

        

# Badar ๐ŸŒ•

Badar _(Full moon in Arabic)_ is a declarative, retained\* and flexbox inspired ui library, with focus on reactivity and composition in mind.

### Getting Started

Badar adapts the `lรถve2d` mentality. You can define a variable in `love.load`, and invoke `render` in `love.draw`. Other callback functions (e.g, `mousepressed`, `mousemoved`) are used in the same manner.

- [API](docs/Core.md)
- [Components โœจ](components)

### Usage

```lua
function love.load()
local container = require 'path.to.badar.lua'
local button = require 'components.button'
local text = require 'components.text'

local counter = text(0)
main = container({ width = screenWidth, height = screenHeight })
.style({ padding = { 16, 16, 16, 16 } })
.content({
counter,
button('add').onClick(function()
counter.text = counter.text + 1
end)
}, { direction = 'column', gap = 8 })
end

function love.draw()
main.render()
end

function love.mousepressed(x, y, button, istouch)
main.mousepressed(button) -- only mouse button needed
end
```

## License

This library is free software; you can redistribute it and/or modify it under
the terms of the MIT license. See [LICENSE](LICENSE) for details.