14 min read

Source: Roblox Creator Hub · CC BY 4.0 · View source · Code samples: MIT Imported 2026-10-03. Formatting adapted for this site.

StyleRule

Inherits from: StyleBase → Instance → Object

Defines style properties which override properties on the instances affected by the Selector property.

Inherits from: StyleBase

Memory category: Gui

Properties

NameType / ReturnsDescription
StyleRule.PriorityintA number that determines how properties of the StyleRule apply relative to the same properties in other StyleRules. Higher priority values take precedence over lower.
StyleRule.SelectorstringA string specifying which instances the StyleRule should affect.
StyleRule.SelectorErrorstringA read-only string that displays errors from the Selector property.

Inherited from Instance

NameType / ReturnsDescription
Instance.ArchivablebooleanDetermines if an Instance and its descendants can be cloned using Instance:Clone(), and can be saved/published.
Instance.archivableboolean
Instance.CapabilitiesSecurityCapabilitiesThe set of capabilities allowed to be used for scripts inside this container.
Instance.IsInSandboxbooleanIndicates whether the instance is inside a sandboxed container.
Instance.NamestringA non-unique identifier of the Instance.
Instance.ParentInstanceDetermines the hierarchical parent of the Instance.
Instance.PredictionModePredictionModeReflects the client-side prediction mode applied to the instance under server-authoritative physics.
Instance.RobloxLockedbooleanA deprecated property that used to protect CoreGui objects.
Instance.SandboxedbooleanWhen enabled, the instance can only access abilities in its Capabilities list.
Instance.UniqueIdUniqueIdA unique identifier for the instance.

Inherited from Object

NameType / ReturnsDescription
Object.ClassNamestringA read-only string representing the class this Object belongs to.
Object.classNamestring

StyleRule.Priority

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.

FieldValue
typeint
security{"read":"None","write":"None"}
thread safetyReadSafe
categoryData
serialization{"can_load":true,"can_save":true}
capabilities["UI"]

StyleRule.Selector

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"
FieldValue
typestring
security{"read":"None","write":"None"}
thread safetyReadSafe
categoryData
serialization{"can_load":true,"can_save":true}
capabilities["UI"]

Code samples: View on Creator Hub (UI-Styling-Class, UI-Styling-Tag, UI-Styling-Modifier, UI-Styling-StyleQuery).

StyleRule.SelectorError

A read-only string that displays errors from the Selector property such as syntax errors, unsupported class types, etc.

FieldValue
typestring
tags["ReadOnly","NotReplicated"]
security{"read":"None","write":"None"}
thread safetyReadSafe
categoryData
serialization{"can_load":false,"can_save":false}
capabilities["UI"]

Methods

NameType / ReturnsDescription
StyleRule:GetDefaultPropertyTransitionVariantReturns the default transition applied to all properties of the StyleRule that don't have an explicit transition set.
StyleRule:GetPropertiesDictionaryReturns a dictionary of key-value pairs describing the properties of the StyleRule.
StyleRule:GetPropertyVariantReturns the value of a specific property in the StyleRule.
StyleRule:GetPropertyTransitionsDictionaryReturns a dictionary of all property transitions set on the StyleRule.
StyleRule:SetDefaultPropertyTransition()Sets or clears a default transition that applies to all properties of the StyleRule that don't have an explicit transition set.
StyleRule:SetProperties()Lets you declare and set multiple properties of the StyleRule at once.
StyleRule:SetProperty()Sets or updates a single property of the StyleRule.
StyleRule:SetPropertyTransition()Sets or clears the transition for a single property on the StyleRule.
StyleRule:SetPropertyTransitions()Lets you declare and set transitions for multiple properties of the StyleRule at once.

Inherited from StyleBase

NameType / ReturnsDescription
StyleBase:GetStyleRulesListReturns an array of associated StyleRules.
StyleBase:InsertStyleRule()Inserts a new StyleRule into the array of rules.
StyleBase:SetStyleRules()Similar to InsertStyleRule() but lets you declare and set multiple StyleRules at once.

Inherited from Instance

NameType / ReturnsDescription
Instance:AddTag()Applies a tag to the instance.
Instance:childrenInstancesReturns an array of the object's children.
Instance:ClearAllChildren()This method destroys all of an instance's children.
Instance:CloneInstanceCreate a copy of an instance and all its descendants, ignoring instances that are not Archivable.
Instance:cloneInstance
Instance:Destroy()Sets the Instance.Parent property to nil, locks the Instance.Parent property, disconnects all connections, and calls Destroy() on all children.
Instance:destroy()
Instance:FindFirstAncestorInstance?Returns the first ancestor of the Instance whose Instance.Name is equal to the given name.
Instance:FindFirstAncestorOfClassInstance?Returns the first ancestor of the Instance whose Object.ClassName is equal to the given className.
Instance:FindFirstAncestorWhichIsAInstance?Returns the first ancestor of the Instance for whom Object:IsA() returns true for the given className.
Instance:FindFirstChildInstance?Returns the first child of the Instance found with the given name.
Instance:findFirstChildInstance
Instance:FindFirstChildOfClassInstance?Returns the first child of the Instance whose ClassName is equal to the given class name.
Instance:FindFirstChildWhichIsAInstance?Returns the first child of the Instance for whom Object:IsA() returns true for the given className.
Instance:FindFirstDescendantInstance?Returns the first descendant found with the given Instance.Name.
Instance:GetActorActor?Returns the Actor associated with the Instance, if any.
Instance:GetAttributeVariantReturns the value which has been assigned to the given attribute name.
Instance:GetAttributeChangedSignalRBXScriptSignalReturns an event that fires when the given attribute changes.
Instance:GetAttributesDictionaryReturns a dictionary of the instance's attributes.
Instance:GetChildrenInstancesReturns an array containing all of the instance's children.
Instance:getChildrenInstances
Instance:GetDebugIdstringReturns a coded string of the debug ID used internally by Roblox.
Instance:GetDescendantsInstancesReturns an array containing all of the descendants of the instance.
Instance:GetFullNamestringReturns a string describing the instance's ancestry.
Instance:GetStyledVariantReturns the styled or explicitly modified value of the specified property, or else the default property value if it hasn't been styled/modified.
Instance:GetStyledPropertyChangedSignalRBXScriptSignalReturns an event that fires when the given style property changes on the instance.
Instance:GetTagsArrayGets an array of all tags applied to the instance.
Instance:HasTagbooleanCheck whether the instance has a given tag.
Instance:IsAncestorOfbooleanReturns true if an Instance is an ancestor of the given descendant.
Instance:IsDescendantOfbooleanReturns true if an Instance is a descendant of the given ancestor.
Instance:isDescendantOfboolean
Instance:IsPropertyModifiedbooleanReturns true if the value stored in the specified property is not equal to the code-instantiated default.
Instance:QueryDescendantsInstancesReturns an array containing all descendants of the instance that match the selector string.
Instance:Remove()Sets the object's Parent to nil, and does the same for all its descendants.
Instance:remove()
Instance:RemoveTag()Removes a tag from the instance.
Instance:ResetPropertyToDefault()Resets a property to its default value.
Instance:SetAttribute()Sets the attribute with the given name to the given value.
Instance:WaitForChildInstanceReturns the child of the Instance with the given name. If the child does not exist, it will yield the current thread until it does.

Inherited from Object

NameType / ReturnsDescription
Object:GetPropertyChangedSignalRBXScriptSignalGet an event that fires when a given property of the object changes.
Object:IsAbooleanReturns true if an object's class matches or inherits from a given class.
Object:isAboolean

StyleRule:GetDefaultPropertyTransition

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

TypeDescription
VariantThe default transition as a TweenInfo or string token, or nil if no default transition is set.
FieldValue
securityNone
thread safetyUnsafe
capabilities["UI"]

StyleRule:GetProperties

Returns a dictionary of key-value pairs describing the properties of the StyleRule, for example:

Returns

TypeDescription
DictionaryDictionary of key-value pairs describing the properties of the StyleRule.
FieldValue
securityNone
thread safetyUnsafe
capabilities["UI"]

Code samples: View on Creator Hub (StyleRule-GetProperties).

StyleRule:GetProperty

Returns the value of a specific property in the StyleRule.

Parameters

NameTypeDefaultDescription
namestringString name of the property, for example "AnchorPoint" or "BackgroundColor3".

Returns

TypeDescription
VariantValue of the property.
FieldValue
securityNone
thread safetyUnsafe
capabilities["UI"]

Code samples: View on Creator Hub (StyleRule-GetProperty).

StyleRule:GetPropertyTransitions

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

TypeDescription
DictionaryDictionary of key-value pairs mapping property names to their transition parameters.
FieldValue
securityNone
thread safetyUnsafe
capabilities["UI"]

Code samples: View on Creator Hub (StyleRule-GetPropertyTransitions).

StyleRule:SetDefaultPropertyTransition

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:

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.

Parameters

NameTypeDefaultDescription
transitionParamsVariantEither a TweenInfo, a token string defining the default transition timing, or nil to remove the default transition.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe
capabilities["UI"]

StyleRule:SetProperties

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"
})

Parameters

NameTypeDefaultDescription
stylePropertiesDictionaryDictionary of key-value pairs defining the properties to set.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe
capabilities["UI"]

StyleRule:SetProperty

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")

Parameters

NameTypeDefaultDescription
namestringProperty name to set, for example "BackgroundColor3".
valueVariantProperty value to set, for example Color3.new(1, 0, 0.25).

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe
capabilities["UI"]

StyleRule:SetPropertyTransition

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:

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().

Parameters

NameTypeDefaultDescription
propertystringString name of the property to set a transition for, for example "BackgroundColor3" or "Size".
transitionParamsVariantA TweenInfo or token string defining the transition timing, or nil to remove the transition for this property.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe
capabilities["UI"]

Code samples: View on Creator Hub (StyleRule-SetPropertyTransition, StyleRule-SetPropertyTransition-Tokens).

StyleRule:SetPropertyTransitions

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:

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().

Parameters

NameTypeDefaultDescription
propertiesDictionaryDictionary of property names to transition parameters.

Returns

TypeDescription
()
FieldValue
securityNone
thread safetyUnsafe
capabilities["UI"]

Code samples: View on Creator Hub (StyleRule-SetPropertyTransitions, StyleRule-SetPropertyTransitions-Tokens).

Events

Inherited from StyleBase

NameType / ReturnsDescription
StyleBase.StyleRulesChangedFires when one or more StyleRules is explicitly changed on the connected StyleSheet or StyleRule.

Inherited from Instance

NameType / ReturnsDescription
Instance.AncestryChangedFires when the Instance.Parent property of this object or one of its ancestors is changed.
Instance.AttributeChangedFires whenever an attribute is changed on the Instance.
Instance.ChildAddedFires after an object is parented to this Instance.
Instance.childAdded
Instance.ChildRemovedFires after a child is removed from this Instance.
Instance.DescendantAddedFires after a descendant is added to the Instance.
Instance.DescendantRemovingFires immediately before a descendant of the Instance is removed.
Instance.DestroyingFires immediately before (or is deferred until after) the instance is destroyed via Instance:Destroy().
Instance.StyledPropertiesChangedFires whenever any style property is changed on the instance, including when a property is set to nil.

Inherited from Object

NameType / ReturnsDescription
Object.ChangedFires immediately after a property of the object changes, with some limitations.