pesde twistedsignal / ui

Getting started

ui connects reactive state and animation to UI that you built in Roblox Studio. It does not create Instances or render a component tree.

Install

Add the package to wally.toml:

[dependencies]
ui = "twistedsignal/[email protected]"

Run wally install, then map the generated Packages directory into your Rojo project. Require the package from the mapped location:

local ui = require(ReplicatedStorage.Packages.ui)

Bind existing UI

The keys in a binding tree resolve in this order: property, event, then child. A property accepts a constant, reactive value, Rx observable, or reactive expression. An event accepts a callback. A child accepts another binding table.

local open = ui.value(false)
local scale = ui.spring(function(): number
	return if open() then 1 else 0.9
end, { frequency = 7, damping = 0.75 })

local cleanup = ui.bind(screenGui, {
	Panel = {
		Visible = open,
		UIScale = { Scale = scale },
		Toggle = {
			Activated = function(): ()
				open(not open())
			end,
		},
	},
})

Call cleanup() when the UI is removed. Calling it more than once is safe. The bind also stops itself when its root Instance is destroyed.

Next

Read Reactive state for values and effects, or Motion for springs and tweens. The API tab contains the generated reference.