What is Pract?
Github: https://github.com/ambers-careware/pract
Documentation: Getting Started - Pract
Releases: Download the rbxm or zip file here
Pract is a declarative UI library, similar to existing libraries like LPGHatGuy’s Roact and Elttob’s Fusion, for building large-scale UI projects.
NOTE: Pract requires an intermediate understanding of Luau, and is compatible with both Rojo and Studio-only projects. Pract is best used in Luau’s --!strict mode.
Why Use Pract Over Other UI Libraries?
Unlike Roact/Fusion, Pract allows you to use pre-existing templates which will be cloned or decorated by your Pract code, rather than having to specify every single property of your UI objects in code. This means your code will look a lot more concise and flexible, and you can design your UI visuals through Roblox’s UI editor!
Pract is also compatible with Luau’s strict mode, and should not emit any script analysis warnings in your project (unlike Roact/Fusion).
Example Pract Code
With Pract, you can design your entire UI tree in code:
--!strict
local Pract = require(game.ReplicatedStorage.Pract)
local PlayerGui = game.Players.LocalPlayer:WaitForChild('PlayerGui')
-- Create our virtual GUI elements
local element = Pract.create('ScreenGui', {ResetOnSpawn = false}, {
HelloLabel = Pract.create('TextLabel', {
Text = 'Hello, Pract!',
TextSize = 24,
BackgroundTransparency = 1,
Position = UDim2.fromScale(0.5, 0.35),
AnchorPoint = Vector2.new(0.5, 0.5)
})
})
-- Mount our virtual GUI elements into real instances,
-- parented to PlayerGui
local virtualTree = Pract.mount(element, PlayerGui)
Alternatively, you can use a template instead, and write more concise and flexible code:
--!strict
local Pract = require(game.ReplicatedStorage.Pract)
local PlayerGui = game.Players.LocalPlayer:WaitForChild('PlayerGui')
-- Create our virtual GUI elements from a cloned template
-- under this script
local element = Pract.stamp(script.MyGuiTemplate, {}, {
HelloLabel = Pract.decorate({Text = 'Hello, Pract!'})
})
-- Mount our virtual GUI elements into real instances,
-- parented to PlayerGui
local virtualTree = Pract.mount(element, PlayerGui)
Both examples can generate the same instances:
Installation
You can install Pract using one of the following methods:
Method 1: Inserting Pract directly into your place
- Download the latest rbxm release on Github
- Right click the object in the Roblox Studio Explorer that you want to insert Pract into (such as ReplicatedStorage) and select
Insert from File...
- Locate the rbxm file that you downloaded and click
Open
Method 2: Syncing via Rojo
- Install Rojo and initialize your game as a Rojo project if you have not already done so
- Download the latest Source Code release (zip file) on Github
- Extract the
Pract
folder from the repository into a location of your choosing within your Rojo project’s source folder (e.g.src/shared
) - Sync your project using Rojo
Documentation
I have written a full documentation for Pract on the GitHub. The examples and API are subject to change in the future.
Contributing
While I have written the initial release of Pract on my own, Pract is a public domain and open source project. If you like the library and would like to contribute to the addition of new features, bugfixing, unit testing, or documentation, please let me know!
If anyone wants to help in the creation of a community Discord server for the Pract library, send me a DM on the devforum! This will depend on how well-received and widely-used the Pract library becomes after this first release post.