Pract - A Declarative UI Library That's Just Practical!

Typically with Roact/Fusion, you have to write out every single property on every single object in your UI.

This can end up with really long code:

Example using Roact-like/Fusion-like elements:
local myLuckyNumber = math.random(1, 99)

local element = Pract.create('ScreenGui', {ResetOnSpawn = false}, {
    HelloLabel = Pract.create('TextLabel', {
        TextSize = 30,
        TextColor3 = Color3.fromRGB(0, 0, 0),
        Font = Enum.Font.GothamBold,
        Position = UDim2.fromScale(0.5, 0.5),
        AnchorPoint = Vector2.new(0.5, 0.5),
        Size = UDim2.fromOffset(100, 100),
        BackgroundTransparency = 1,
        Text = string.format('Your lucky number is %d', myLuckyNumber)})
    })
})

The more complex your UI design is, the worse this code will look.
With Pract, you can simply design this template in Roblox Studio, and then write a much concise code that looks and functions exactly the same:

local myLuckyNumber = math.random(1, 99)

local element = Pract.stamp(script.HelloPractTemplate, {}, {
    HelloLabel = Pract.decorate({
        Text = string.format('Your lucky number is %d', myLuckyNumber)
    })
})

People typically use tools like Roactify or Hydrogen to convert their UI to a Roact/Fusion component, but you have to re-write the functional parts of your code every time you want to run the converter again.

Pract lets you design your code whichever way you want; if you use templates, it will be much faster both to write your UI code and to design your UI; It also becomes possible to edit your UI’s design without actually changing the code.

Both methods will end up looking like this when you play the game:

4 Likes