Style
The Style module is used to re-create CSS way of styling UI components with scoped, global and reusable class-based styles.
Style.DefineGlobal(styles) -> void
Parameters
- styles
- Type:
table
- Required:
Yes
- Description: A table defining global styles, where each key is a component name, and the value is a table of properties to apply globally to that component type.
- Type:
Returns
- void
- Type:
nil
- Always:
Yes
- Description: No return value; the global styles are added to the
globalStyles
table for later retrieval.
- Type:
Description
Creates and defines global style properties for all UI components of the same class.
lua
Vuxel.Style.DefineGlobal({
Frame = { BackgroundColor3 = Color3.fromRGB(255, 255, 255) }
})
Style.DefineScope(componentName, styles) -> void
Parameters
- componentName
- Type:
string
- Required:
Yes
- Description: The name of the component to which scoped styles will be applied.
- Type:
- styles
- Type:
table
- Required:
Yes
- Description: A table of properties and values that will be applied as scoped styles for the specified component.
- Type:
Returns
- void
- Type:
nil
- Always:
Yes
- Description: No return value; scoped styles are added to the
scopedStyles
table for the specific component.
- Type:
Description
Creates and defines scoped style properties for one UI component.
lua
Vuxel.Style.DefineScope("Button", {
BackgroundColor3 = Color3.fromRGB(0, 170, 255),
Size = UDim2.new(0, 200, 0, 50),
UICorner = { CornerRadius = UDim.new(0, 10) }
})
Style.DefineClass(className, properties) -> void
Parameters
- className
- Type:
string
- Required:
Yes
- Description: The name of the reusable class-based style.
- Type:
- properties
- Type:
table
- Required:
Yes
- Description: A table containing properties and values for the class-based style.
- Type:
Returns
- void
- Type:
nil
- Always:
Yes
- Description: No return value; class-based style is stored in the
classes
table. If a class with the same name already exists, a warning is displayed, and the style is overwritten.
- Type:
Description
Creates and defines a class style for later use.
lua
Vuxel.Style.DefineClass("Primary", {
BackgroundColor3 = Color3.fromRGB(0, 123, 255)
})
Style.GetStyle(componentName, classNames) -> appliedStyle
Parameters
- componentName
- Type:
string
- Required:
Yes
- Description: The name of the component whose style should be retrieved.
- Type:
- classNames
- Type:
table | nil
- Required:
No
- Description: An optional array of class names to apply to the component, with class-based styles overriding global and scoped styles.
- Type:
Returns
- appliedStyle
- Type:
table
- Always:
Yes
- Description: A table containing the final set of properties and values applied to the component, with class-based styles taking priority, followed by scoped, and finally global styles.
- Type:
Description
Get's all the applied styles of a component.
lua
print(Vuxel.Style.GetStyle("Button"))