Skip to content

Functional Components

Jamie Nichols edited this page Jan 24, 2022 · 2 revisions

Component Structure

A component is a function that returns an Array of Elements. That's All. Here is an example of the most basic of components

--[[ src/App.lua ]]--
local div = require "beastcraft".ui.div
local monitor = require "beastcraft".utils.monitor

local App = function()
	local WIDTH,HEIGHT = monitor.getSize()
	return div({
		style = {
			top=1,
			left=1,
			width = WIDTH,
			height = HEIGHT,
			backgroundColor = colors.blue
		}
	})
end
return App

Beastcraft Libraries

Beastcraft has a handful of basic essential libraries for creating elements and helpful tools A list of attributes and methods exposed by the beastcraft require can be found <HERE(link to Beastcraft returns)>

Libraries

Elements Div
Button
Input
State useState
useRef
useReducer
createContext
useContext
Utils monitor
switch
Elements map
filter
debugger printTable
Clone this wiki locally