Class
StyleRule
Defines style properties which override properties on the instances affected
by the Selector property.
Defines style properties which override properties on the instances affected
by the Selector property.
Properties 3#
Priorityint | 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.ReadSafe |
Selectorstring | A string specifying which instances the StyleRule should affect.ReadSafe |
SelectorErrorstring | A read-only string that displays errors from the
Selector property.ReadSafeReadOnlyNotReplicated |
Priority: int#
ReadSafe
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, it will take precedence over lower-priority
StyleRules with AnchorPoint properties.
Selector: string#
ReadSafe
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 Class.GuiObject or Class.UIComponent class. |
"Frame""ImageButton""UICorner" |
.[tag] |
Matches instances tagged with a Class.CollectionService tag. |
".Container"".BlueOnHover" |
#[name] |
Matches instances of a specific Class.Instance.Name. |
"#ModalFrame""#CloseButton" |
:[state] |
Matches instances currently in a Enum.GuiState. |
":Hover" |
@[StyleQuery name] |
Matches instances with child Class.StyleQuery that has Class.StyleQuery.IsActive|IsActive set to true.There are also built-in selectors for "@ReducedMotionEnabledFalse", "@ReducedMotionEnabledTrue", "@PreferredInputGamepad", "@PreferredInputKeyboardAndMouse", "@PreferredInputTouch", "@PreferredTextSizeMedium", "@PreferredTextSizeLarge", "@PreferredTextSizeLarger", "@PreferredTextSizeLargest", "@ViewportDisplaySizeSmall", "@ViewportDisplaySizeMedium", and "@ViewportDisplaySizeLarge" that can match an instance without a Class.StyleQuery instance. |
"@StyleQuerySmall" |
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 Class.UIComponent instance under the previous filter matches and applies the style rule's properties to it.Multiple instances can be created for Class.StyleQuery and Class.UIStroke by aliasing the instance with a name selector.
Some nested instances are supported, including Class.UIGradient under Class.UIStroke or Class.UIConstraint under a Class.UIGridLayout. |
"Frame::UICorner" "::UIStroke #Outer" |
SelectorError: string#
ReadOnlyNotReplicatedReadSafe
A read-only string that displays errors from the
Selector property such as syntax errors,
unsupported class types, etc.
Methods 9#
| GetDefaultPropertyTransition | Returns the default transition applied to all properties of the
StyleRule that don't have an explicit transition set. |
| GetProperties | Returns a dictionary of key-value pairs describing the properties of the
StyleRule. |
| GetProperty | Returns the value of a specific property in the StyleRule. |
| GetPropertyTransitions | Returns a dictionary of all property transitions set on the StyleRule. |
| SetDefaultPropertyTransition | Sets or clears a default transition that applies to all properties of the
StyleRule that don't have an explicit transition set. |
| SetProperties | Lets you declare and set multiple properties of the StyleRule at once. |
| SetProperty | Sets or updates a single property of the StyleRule. |
| SetPropertyTransition | Sets or clears the transition for a single property on the StyleRule. |
| SetPropertyTransitions | Lets you declare and set transitions for multiple properties of the
StyleRule at once. |
GetDefaultPropertyTransition(): Variant#
Returns the default transition applied to all properties of the
StyleRule that don't have an explicit transition set. This is equivalent
to calling
GetPropertyTransitions() and
reading the value at key "*".
Returns
Variant— The default transition as aTweenInfoor string token, ornilif no default transition is set.
GetProperties(): Dictionary#
Returns a dictionary of key-value pairs describing the properties of the
StyleRule, for example:
Returns
Dictionary— Dictionary of key-value pairs describing the properties of theStyleRule.
GetProperty(name: string): Variant#
Returns the value of a specific property in the StyleRule.
| Name | Type | Default | Description |
|---|---|---|---|
name | string | String name of the property, for example "AnchorPoint" or
"BackgroundColor3". |
Returns
Variant— Value of the property.
GetPropertyTransitions(): Dictionary#
Returns a dictionary of all property transitions set on the StyleRule.
Each key is a property name (string) and each value is a
TweenInfo or a string token that defines the transition's
timing for that property.
Returns
Dictionary— Dictionary of key-value pairs mapping property names to their transition parameters.
SetDefaultPropertyTransition(transitionParams: Variant): ()#
Sets or clears a default transition that applies to all properties of the
StyleRule that don't have an explicit transition set. This is equivalent
to calling
SetPropertyTransition() with
"*" as the property name.
The transitionParams parameter accepts a TweenInfo that
configures the transition's timing. The following TweenInfo
properties are used:
Time— Duration of the transition in seconds.EasingStyle— The easing function used for interpolation.EasingDirection— The direction of the easing function.DelayTime— Delay in seconds before the transition starts.
Note that the RepeatCount and
Reverses fields of TweenInfo are
ignored, as style transitions cannot repeat or reverse automatically.
A per-property transition set via
SetPropertyTransition() takes
precedence over the default transition for that property.
| Name | Type | Default | Description |
|---|---|---|---|
transitionParams | Variant | Either a TweenInfo, a token string defining the default
transition timing, or nil to remove the default transition. |
Returns
()
SetProperties(styleProperties: Dictionary): ()#
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().
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
-- Get reference to style rule
local frameRule = coreSheet.Frame
-- Set rule properties
frameRule:SetProperties({
["AnchorPoint"] = Vector2.new(0.5, 0),
["BackgroundColor3"] = Color3.new(1, 0, 0.25)
})Note that you can assign tokens as property values through the $
prefix:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
local tokensSheet = ReplicatedStorage:FindFirstChild("Tokens")
-- Set tokens (attributes) on tokens sheet
tokensSheet:SetAttribute("TopCenterAnchor", Vector2.new(0.5, 0))
tokensSheet:SetAttribute("MainBackgroundColor", Color3.new(0.2, 0.2, 0.3))
-- Get reference to style rule
local frameRule = coreSheet.Frame
-- Set rule properties
frameRule:SetProperties({
["AnchorPoint"] = "$TopCenterAnchor",
["BackgroundColor3"] = "$MainBackgroundColor"
})| Name | Type | Default | Description |
|---|---|---|---|
styleProperties | Dictionary | Dictionary of key-value pairs defining the properties to set. |
Returns
()
SetProperty(name: string, value: Variant): ()#
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().
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
-- Get reference to style rule
local frameRule = coreSheet.Frame
-- Set rule property
frameRule:SetProperty("BackgroundColor3", Color3.new(1, 0, 0.25))Note that you can assign tokens as property values through the $
prefix:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
local tokensSheet = ReplicatedStorage:FindFirstChild("Tokens")
-- Set new token (attribute) on tokens sheet
tokensSheet:SetAttribute("MainBackgroundColor", Color3.new(0.2, 0.2, 0.3))
-- Get reference to style rule
local frameRule = coreSheet.Frame
-- Set rule property to use the token as its value
frameRule:SetProperty("BackgroundColor3, "$MainBackgroundColor")| Name | Type | Default | Description |
|---|---|---|---|
name | string | Property name to set, for example "BackgroundColor3". | |
value | Variant | Property value to set, for example Datatype.Color3.new(1, 0, 0.25). |
Returns
()
SetPropertyTransition(property: string, transitionParams: Variant): ()#
Sets or clears the transition for a single property on the StyleRule.
When a transition is set for a property, any change to that property's
styled value will be animated over time instead of applied immediately.
The transitionParams parameter accepts a TweenInfo that
configures the transition's timing. The following TweenInfo
properties are used:
Time— Duration of the transition in seconds.EasingStyle— The easing function used for interpolation.EasingDirection— The direction of the easing function.DelayTime— Delay in seconds before the transition starts.
Note that the RepeatCount and
Reverses fields of TweenInfo are
ignored, as style transitions cannot repeat or reverse automatically.
To set transitions for multiple properties at once, see
SetPropertyTransitions().
| Name | Type | Default | Description |
|---|---|---|---|
property | string | String name of the property to set a transition for, for example
"BackgroundColor3" or "Size". | |
transitionParams | Variant | A TweenInfo or token string defining the transition timing,
or nil to remove the transition for this property. |
Returns
()
SetPropertyTransitions(properties: Dictionary): ()#
Similar to
SetPropertyTransition() but lets
you declare and set transitions for multiple properties of the StyleRule
at once.
Calling this method replaces all existing transitions on the
StyleRule with the provided set. Each key should be a property name
(string) and each value should be a TweenInfo or string token
defining the transition timing for that property. Passing nil as a value
for a key excludes that property from the resulting transitions.
The following TweenInfo properties are used:
Time— Duration of the transition in seconds.EasingStyle— The easing function used for interpolation.EasingDirection— The direction of the easing function.DelayTime— Delay in seconds before the transition starts.
Note that the RepeatCount and
Reverses fields of TweenInfo are
ignored, as style transitions cannot repeat or reverse automatically.
To set/update just one property transition on a StyleRule, see
SetPropertyTransition().
| Name | Type | Default | Description |
|---|---|---|---|
properties | Dictionary | Dictionary of property names to transition parameters. |
Returns
()
Inherited members#
Inherited from Instance 58
Properties (10)
Archivable, archivable, Capabilities, IsInSandbox, Name, Parent, PredictionMode, RobloxLocked, Sandboxed, UniqueId
Methods (39)
AddTag, children, ClearAllChildren, Clone, clone, Destroy, destroy, FindFirstAncestor, FindFirstAncestorOfClass, FindFirstAncestorWhichIsA, FindFirstChild, findFirstChild, FindFirstChildOfClass, FindFirstChildWhichIsA, FindFirstDescendant, GetActor, GetAttribute, GetAttributeChangedSignal, GetAttributes, GetChildren, getChildren, GetDebugId, GetDescendants, GetFullName, GetStyled, GetStyledPropertyChangedSignal, GetTags, HasTag, IsAncestorOf, IsDescendantOf, isDescendantOf, IsPropertyModified, QueryDescendants, Remove, remove, RemoveTag, ResetPropertyToDefault, SetAttribute, WaitForChild