Roblox UtilitiesDevlHub Roblox Documentation

Class

StyleQuery

Inherits
Instance › Object
Memory category
Instances

Instance used to set conditions such as "MaxSize" and "PreferredInput" for a StyleRule.

StyleQuery is an instance used to set conditions like "MaxSize" and "PreferredInput" for a StyleRule. If the conditions are true, the rule's @ selector is enabled. This is helpful to author styling with dynamic container sizes and cross-platform UI.

Properties 1#

IsActivebooleanA boolean that determines whether a StyleRule.Selector of @ will match the StyleQuery name.ReadSafeReadOnlyNotReplicated

IsActive: boolean#

ReadOnlyNotReplicatedReadSafe

A boolean that determines whether a StyleRule.Selector of @ will match the StyleQuery name. For example, if a StyleQuery named SmGamepad has conditions set for UserInputService.PreferredInput of Gamepad and GuiService.ViewportDisplaySize of Small and both of these conditions are true (player is playing on a small display size and using a gamepad), the parent of the StyleQuery will match any StyleRule.Selector @SmGamepad.

Conditions#

Condition Type Description
AspectRatioRange Datatype.NumberRange Evaluates to true if the parent width-to-height ratio of Class.GuiBase2d.AbsoluteSize is greater than or equal to AspectRatioRange.Min and less than AspectRatioRange.Max.
MaxSize Datatype.Vector2 Evaluates to true if the parent Class.GuiBase2d.AbsoluteSize is less than MaxSize.
MinSize Datatype.Vector2 Evaluates to true if the parent Class.GuiBase2d.AbsoluteSize is greater than or equal to MinSize.
PreferredInput Enum.PreferredInput Evaluates to true if PreferredInput matches Class.UserInputService.PreferredInput.
PreferredTextSize Enum.PreferredTextSize Evaluates to true if PreferredTextSize matches Class.GuiService.PreferredTextSize.
ReducedMotionEnabled boolean Evaluates to true if ReducedMotionEnabled matches Class.GuiService.ReducedMotionEnabled.
ViewportDisplaySize Enum.DisplaySize Evaluates to true if ViewportDisplaySize matches Class.GuiService.ViewportDisplaySize.

Methods 4#

GetConditionReturns the value of a specific condition in the StyleQuery.
GetConditionsReturns a dictionary of key-value pairs describing the conditoins set on the StyleQuery.
SetCondition
SetConditionsLets you declare and set multiple conditions of the StyleQuery at once.

GetCondition(name: string): Variant#

Returns the value of a specific condition in the StyleQuery.

NameTypeDefaultDescription
namestringString name of the condition, for example "MaxSize" or "ViewportDisplaySize".
Returns
  • Variant — Value of the condition.

GetConditions(): Dictionary#

Returns a dictionary of key-value pairs describing the conditoins set on the StyleQuery.

Returns
  • Dictionary — Dictionary of key-value pairs describing the conditions set on the StyleQuery.

SetCondition(name: string, value: Variant): ()#

Sets a new condition (or modifies an existing condition) for the StyleQuery. The name parameter should be a valid condition of StyleQuery, and the assigned value should match the condition's value type, for example Vector2 for MaxSize or PreferredInput for PreferredInput.

Attempts to assign invalid condition names such as "Size" or "Input" will silently fail. Type mismatches such as UDim2 for MaxSize or string for ReducedMotionEnabled will also fail.

To set multiple conditions for a StyleQuery at once, see SetConditions().

NameTypeDefaultDescription
namestringCondition name to set, for example "MinSize".
valueVariantCondition value to set, for example Datatype.Vector2.new(100, 0).
Returns
  • ()

SetConditions(conditions: Dictionary): ()#

Similar to SetCondition() but lets you declare and set multiple conditions of the StyleQuery at once. Each name parameter should be a valid condition of StyleQuery, and the assigned value should match the condition's value type, for example Vector2 for MaxSize or PreferredInput for PreferredInput.

Attempts to assign invalid condition names such as "Size" or "Input" will silently fail. Type mismatches such as UDim2 for MaxSize or string for ReducedMotionEnabled will also fail.

To set/update just one condition of a StyleQuery, see SetCondition().

NameTypeDefaultDescription
conditionsDictionaryDictionary of key-value pairs defining the conditions to set.
Returns
  • ()

Inherited members#

Inherited from Instance 58
Inherited from Object 6
Properties (2)

ClassName, className

Events (1)

Changed