Class
StyleQuery
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#
IsActiveboolean | A 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#
| GetCondition | Returns the value of a specific condition in the StyleQuery. |
| GetConditions | Returns a dictionary of key-value pairs describing the conditoins set on
the StyleQuery. |
| SetCondition | |
| SetConditions | Lets 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.
| Name | Type | Default | Description |
|---|---|---|---|
name | string | String 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 theStyleQuery.
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().
| Name | Type | Default | Description |
|---|---|---|---|
name | string | Condition name to set, for example "MinSize". | |
value | Variant | Condition 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().
| Name | Type | Default | Description |
|---|---|---|---|
conditions | Dictionary | Dictionary of key-value pairs defining the conditions to set. |
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