Firstly to mention, I don’t like UI Frameworks.
Yeah its probably a good idea to keep all my interfaces organized in code.
But I can’t find one I like. I’ve tried Fusion, React, Rex. I wanted to combine both my UX and UI in the same script.
CXUI, is something I made for myself, it’s simple, light, and very fluid and easy to understand.
Documentation
--How it works, *psuedocode*
local interface = cxui:New{
"ScreenGui", -- Create a ScreenGui
{ -- Child Stack
"TextLabel", -- Create a TextLabel
}
}
interface is a cxuiStack, it can operate like a instance except for stuff that are especially for Instances like Tweening, or functions that actually require instances. To get the base instance, you to stack.inst or in this case interface.inst which would be the ScreenGui.
How it operates as a instance, To set ScreenGui Enabled to true, you can just do interface.Enabled = true, you wouldn’t need to get the base instance and set it to true.
How to mount
You can’t set cxuiStacks to a parent, you need to mount them (you can set the base instance to a parent though). You can mount it by doing cxui.mount(cxuiStack, parent) or better just do cxuiStack:mount(parent). For example to mount interface to workspace, you would do interface:mount(workspace) (obviously mounting can work with other cxuiStacks!)
Properties, simplifed
local cxui = require(workspace:WaitForChild("cxui"));
local interface = cxui:New{
"ScreenGui", -- Create a ScreenGui
{ -- Child Stack
"TextLabel", -- Create a TextLabel
Size = UDim2.fromOffset(200, 50), -- Set Size
Text = 'lol', -- Set Text
Position = UDim2.fromScale(.5, .5), -- Set Position
AnchorPoint = Vector2.new(.5, .5) -- Set AnchorPoint
}
}
Name stuff: To set the name for the cxuiStack, you can do
{ -- Child Stack
"TextLabel", -- Create a TextLabel
Name = "Label",
But you could just do
{ -- Child Stack
"TextLabel", -- Create a TextLabel
"Label",
Wrapping!!! My favorite part
You can add a function in the properties for the cxuiStack so when the module parses thru the data, it can fire the function and give out the the unfinished cxuiStack.
local cxui = require(workspace:WaitForChild("cxui"));
local interface = cxui:New{
"ScreenGui", -- Create a ScreenGui
{ -- Child Stack
"TextLabel", -- Create a TextLabel
Name = "Label",
Size = UDim2.fromOffset(200, 50), -- Set Size
Text = 'lol', -- Set Text
Position = UDim2.fromScale(.5, .5), -- Set Position
AnchorPoint = Vector2.new(.5, .5), -- Set AnchorPoint
function(stack) -- Wrap!!
print(stack) -- TextLabel (cxuiStack)
end,
}
}
(this is especially useful for effects since you could just do)
local cxui = require(workspace:WaitForChild("cxui"));
local interface = cxui:New{
"ScreenGui", -- Create a ScreenGui
{ -- Child Stack
"TextLabel", -- Create a TextLabel
Name = "Label",
Size = UDim2.fromOffset(200, 50), -- Set Size
Text = 'Not', -- Set Text
Position = UDim2.fromScale(.5, .5), -- Set Position
AnchorPoint = Vector2.new(.5, .5), -- Set AnchorPoint
function(stack)
stack.MouseEnter:Connect(function()
stack.Text = "Hovering"
end)
stack.MouseLeave:Connect(function()
stack.Text = "Not"
end)
end,
}
}
interface:mount(game.StarterGui)
Speciality Functions
cxuiStack:FindStack(name) → Finds stack by name (basically FindFirstChid)
cxuiStack:WaitForStack(name) → Waits for stack and returns (basically WaitForChild)cxuiStack:getStackFromName(name) → Gets stack from name (from descendants)
cxuiStack:getStackFromId(id) → Gets stack from Id (from descendants)
To add an id to a stack, make a key named “id” and set it to anythingcxuiStack:Clone() → Clones the stack (NOT THE INSTANCE)
cxuiStack:mount(parent : stackOrInstance) → mounts stack to stack or instance
cxuiStack:unmount() | cxuiStack() → unmounts the stack and the rest of its descendant stack
cxuiStack:Tween() – Tween directly
Special functions for each class
GuiObject
:SetCorner(Scale : number, Offset : number) or :SetCorner(CornerRadius : UDim)
:SetStroke(Thickness : number, Color : hexOrColor3, Transparency : number, LineJoinMode, ApplyStrokeMode))
TextButton
if you add a function in the data named “onClick”, it will automatically setup a connection for MouseButton1Click, same for “onDown” and “onUp”
TextBox
if you add a function in the data named “onFocus”, it will automatically setup a connection for Focused, same if you do “onFocusLost”, it sets up a connection for FocusLost, if you only want a function to execute when it is entered, you can do “onEntered” or “onEnter”
ImageLabel
SetImage(imageContent : string)
ImageButton
SetImage(imageContent : string)
if you add a function in the data named “onClick”, it will automatically setup a connection for MouseButton1Click, same for “onDown” and “onUp”
CanvasGroup
SetGroupTransparency(transparency: number)
Component library
In cxui there is a bulit-in library that can allow you to set components for even better functionality.
Component:New(key, stackData, stackWrap?) → Sets up a new component
Component:Create(key) → Makes the component
local cxui = require(workspace:WaitForChild("cxui"));
cxui.Components:New(1, { -- Make Component `1`
"Frame",
"Component"
})
print(cxui.Components:Create(1)) -- Create Component `1`
(this is really all you need to know)
cxuirevamp.rbxm (9.7 KB)
Update: fixed a dumb bug and removed the stack module

