StyleRule
Defines style properties which override properties on the instances affected by the Selector property.
Memory category | Gui |
---|
Member index 12
Description
Defines style properties which override properties on the instances affected by the Selector property.
History 15
- 664 Change Parameters of SetProperties from (table: Dictionary) to (styleProperties: Dictionary)
- 640 Add Priority
- 640 Change CanSave of from true to false
- 591 Add StyleRulePropertyChanged
- 578 Add SetProperty
- 578 Add SetProperties
- 578 Add GetPropertyResolved
- 578 Add GetProperty
- 578 Add GetPropertiesResolved
- 578 Add GetProperties
- 577 Add SelectorError
- 577 Add Selector
- 577 Add
- 577 Add
- 577 Add StyleRule
Members 12
GetProperties
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
Dictionary |
Returns a dictionary of key-value pairs describing the properties of the StyleRule
, for example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
Thread safety | Unsafe |
---|
History 1
- 578 Add GetProperties
GetPropertiesResolved
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
Dictionary |
Security | RobloxScriptSecurity |
---|---|
Thread safety | Unsafe |
History 1
GetProperty
Parameters (1) | ||
---|---|---|
name | string | |
Returns (1) | ||
Variant |
Returns the value of a specific property in the StyleRule
.
1 2 3 4 5 6 7 8 9 |
|
Thread safety | Unsafe |
---|
History 1
- 578 Add GetProperty
GetPropertyResolved
Parameters (1) | ||
---|---|---|
name | string | |
Returns (1) | ||
Variant |
Security | RobloxScriptSecurity |
---|---|
Thread safety | Unsafe |
History 1
Priority
Type | Default | |
---|---|---|
int | 0 |
A number that determines how properties of the StyleRule
apply relative
to the same properties in other StyleRules. Higher
priority values take precedence over lower. For example, if a StyleRule
with a priority of 10
has an AnchorPoint
property of 1, 0
AnchorPoint
properties.
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | true |
Selector
Type | Default | |
---|---|---|
string |
A string specifying which instances the StyleRule
should affect. This
can be a mix of selectors and combinators to match characteristics such as
the class name, instance name, and hierarchy relationships.
For example, ".Container > ImageLabel.BlueOnHover:Hover"
effectively
means the style rule overrides every ImageLabel that's a child of
an instance tagged with Container
(.Container > ImageLabel
) and is
tagged with BlueOnHover
(.BlueOnHover
) and is in the
GuiState.Hover state (:Hover
).
Selectors
Selector | Description | Examples |
---|---|---|
[class] | Matches instances of a GuiObject or UIComponent class. | "Frame" "ImageButton" "UICorner" |
.[tag] | Matches instances tagged with a CollectionService tag. | ".Container" ".BlueOnHover" |
#[name] | Matches instances of a specific Instance.Name. | "#ModalFrame" "#CloseButton" |
:[state] | Matches instances currently in a GuiState. | ":Hover" |
Combinators
Combinator | Description | Examples |
---|---|---|
> | Matches instances that are direct children of the previous filter matches. | "Frame > .Inventory" |
>> | Matches instances that are descendants of the previous filter matches. | "ImageButton >> .BlueOnHover" |
, | Specifies a list of multiple independent selectors for the style rule. | "Frame.TagA, TextLabel.TagA" |
:: | Creates a phantom UIComponent instance under the previous filter matches and applies the style rule's properties to it. | "Frame::UICorner" |
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | true |
SelectorError
Type | Default | |
---|---|---|
string |
A read-only string that displays errors from the Selector property such as syntax errors, unsupported class types, etc.
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | false |
History 1
- 577 Add SelectorError
SetProperties
Parameters (1) | ||
---|---|---|
styleProperties | Dictionary | |
Returns (1) | ||
null |
Similar to SetProperty() but lets you
declare and set multiple properties of the StyleRule
at once. Each
assignment should be a valid property of the affected GuiObject or
UIComponent (UICorner, UIGradient, etc.), and each
assigned value should match its property's value type, for example
Vector2 for AnchorPoint or
Color3 for BackgroundColor3.
Attempts to assign invalid property names such as "AnchorPt"
or
"BkColor"
will silently fail. Type mismatches such as CFrame
for AnchorPoint or UDim2 for
BackgroundColor3 will also fail and an
error will appear in the Output window.
To set/update just one property of a StyleRule
, see SetProperty().
1 2 3 4 5 6 7 8 9 10 11 12 |
|
Note that you can assign tokens as property values through the $
prefix:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
Thread safety | Unsafe |
---|
History 2
- 664 Change Parameters of SetProperties from (table: Dictionary) to (styleProperties: Dictionary)
- 578 Add SetProperties
SetProperty
Parameters (2) | ||
---|---|---|
name | string | |
value | Variant | |
Returns (1) | ||
null |
Sets a new property (or modifies an existing property) for the
StyleRule
. The name
parameter should be a valid property of the
affected GuiObject or UIComponent (UICorner,
UIGradient, etc.), and the assigned value should match the
property's value type, for example Vector2 for
AnchorPoint or Color3 for
BackgroundColor3.
Attempts to assign invalid property names such as "AnchorPt"
or
"BkColor"
will silently fail. Type mismatches such as CFrame
for AnchorPoint or UDim2 for
BackgroundColor3 will also fail and an
error will appear in the Output window.
To set multiple properties for a StyleRule
at once, see
SetProperties().
1 2 3 4 5 6 7 8 9 |
|
Note that you can assign tokens as property values through the $
prefix:
1 2 3 4 5 6 7 8 9 10 11 12 |
|
Thread safety | Unsafe |
---|
History 1
- 578 Add SetProperty
StyleRulePropertyChanged
Parameters (1) | |
---|---|
styleProperty | string |
Security | RobloxScriptSecurity |
---|---|
Thread safety | Unsafe |