# StyleRule

Roblox Engine API class from Roblox Studio 0.744.0.7441077 (version-7aaa6838d36c4448).

- Inherits from, nearest first: [StyleBase](https://rapi.sleaze.dev/classes/StyleBase.md), [Instance](https://rapi.sleaze.dev/classes/Instance.md), [Object](https://rapi.sleaze.dev/classes/Object.md)
- Memory category: Gui
- HTML page: https://rapi.sleaze.dev/classes/StyleRule/
- Roblox documentation: https://create.roblox.com/docs/reference/engine/classes/StyleRule

Defines style properties which override properties on the instances affected by the [`Selector`](https://rapi.sleaze.dev/classes/StyleRule.md) property.

## Properties

### Index

```luau
StyleRule.Index: number = -1
```

- Tags: Hidden, Not scriptable, Capabilities: UI, Load only

### Priority

```luau
StyleRule.Priority: number = 0
```

- Tags: Capabilities: UI

A number that determines how properties of the [`StyleRule`](https://rapi.sleaze.dev/classes/StyleRule.md) apply relative to the same properties in other `StyleRules`. Higher priority values take precedence over lower.

### PropertiesSerialize

```luau
StyleRule.PropertiesSerialize: string = ""
```

- Tags: Hidden, Not scriptable, Capabilities: UI

### PropertyTransitionsSerialize

```luau
StyleRule.PropertyTransitionsSerialize: string = "\u0002"
```

- Tags: Hidden, Not scriptable, Capabilities: UI

### Selector

```luau
StyleRule.Selector: string = ""
```

- Tags: Capabilities: UI

A string specifying which instances the [`StyleRule`](https://rapi.sleaze.dev/classes/StyleRule.md) should affect.

### SelectorError

```luau
StyleRule.SelectorError: string = ""
```

- Tags: Read only, Capabilities: UI

A read-only string that displays errors from the [`Selector`](https://rapi.sleaze.dev/classes/StyleRule.md) property.

## Methods

### GetDefaultPropertyTransition

```luau
StyleRule:GetDefaultPropertyTransition(): any
```

- Tags: Capabilities: UI

Returns the default transition applied to all properties of the [`StyleRule`](https://rapi.sleaze.dev/classes/StyleRule.md) that don't have an explicit transition set.

Returns: The default transition as a [`TweenInfo`](https://rapi.sleaze.dev/index/types/TweenInfo.md) or string token, or `nil` if no default transition is set.

### GetProperties

```luau
StyleRule:GetProperties(): { [string]: any }
```

- Tags: Capabilities: UI

Returns a dictionary of key-value pairs describing the properties of the [`StyleRule`](https://rapi.sleaze.dev/classes/StyleRule.md).

Returns: Dictionary of key-value pairs describing the properties of the [`StyleRule`](https://rapi.sleaze.dev/classes/StyleRule.md).

### GetPropertiesResolved

```luau
StyleRule:GetPropertiesResolved(): { [string]: any }
```

- Tags: Roblox script security, Capabilities: UI

### GetProperty

```luau
StyleRule:GetProperty(name: string): any
```

- Tags: Capabilities: UI

Returns the value of a specific property in the [`StyleRule`](https://rapi.sleaze.dev/classes/StyleRule.md).

Parameters:

- `name`: String name of the property, for example `"AnchorPoint"` or `"BackgroundColor3"`.

Returns: Value of the property.

### GetPropertyResolved

```luau
StyleRule:GetPropertyResolved(name: string): any
```

- Tags: Roblox script security, Capabilities: UI

### GetPropertyTransitions

```luau
StyleRule:GetPropertyTransitions(): { [string]: any }
```

- Tags: Capabilities: UI

Returns a dictionary of all property transitions set on the [`StyleRule`](https://rapi.sleaze.dev/classes/StyleRule.md).

Returns: Dictionary of key-value pairs mapping property names to their transition parameters.

### SetDefaultPropertyTransition

```luau
StyleRule:SetDefaultPropertyTransition(transitionParams: any)
```

- Tags: Capabilities: UI

Sets or clears a default transition that applies to all properties of the [`StyleRule`](https://rapi.sleaze.dev/classes/StyleRule.md) that don't have an explicit transition set.

Parameters:

- `transitionParams`: Either a [`TweenInfo`](https://rapi.sleaze.dev/index/types/TweenInfo.md), a token string defining the default transition timing, or `nil` to remove the default transition.

### SetProperties

```luau
StyleRule:SetProperties(styleProperties: { [string]: any })
```

- Tags: Capabilities: UI

Lets you declare and set multiple properties of the [`StyleRule`](https://rapi.sleaze.dev/classes/StyleRule.md) at once.

Parameters:

- `styleProperties`: Dictionary of key-value pairs defining the properties to set.

### SetProperty

```luau
StyleRule:SetProperty(name: string, value: any)
```

- Tags: Capabilities: UI

Sets or updates a single property of the [`StyleRule`](https://rapi.sleaze.dev/classes/StyleRule.md).

Parameters:

- `name`: Property name to set, for example `"BackgroundColor3"`.
- `value`: Property value to set, for example `Color3.new(1, 0, 0.25)`.

### SetPropertyTransition

```luau
StyleRule:SetPropertyTransition(property: string, transitionParams: any)
```

- Tags: Capabilities: UI

Sets or clears the transition for a single property on the [`StyleRule`](https://rapi.sleaze.dev/classes/StyleRule.md).

Parameters:

- `property`: String name of the property to set a transition for, for example `"BackgroundColor3"` or `"Size"`.
- `transitionParams`: A [`TweenInfo`](https://rapi.sleaze.dev/index/types/TweenInfo.md) or token string defining the transition timing, or `nil` to remove the transition for this property.

### SetPropertyTransitions

```luau
StyleRule:SetPropertyTransitions(properties: { [string]: any })
```

- Tags: Capabilities: UI

Lets you declare and set transitions for multiple properties of the [`StyleRule`](https://rapi.sleaze.dev/classes/StyleRule.md) at once.

Parameters:

- `properties`: Dictionary of property names to transition parameters.

## Events

### StyleRulePropertyChanged

```luau
StyleRule.StyleRulePropertyChanged: RBXScriptSignal<(styleProperty: string)>
```

- Tags: Roblox script security, Capabilities: UI

## Inherited members

- From [StyleBase](https://rapi.sleaze.dev/classes/StyleBase.md): `GetStyleRules`, `InsertStyleRule`, `SetStyleRules`, `StyleRulesChanged`
- From [Instance](https://rapi.sleaze.dev/classes/Instance.md): `Archivable`, `archivable`, `Attributes`, `AttributesReplicate`, `AttributesSerialize`, `HistoryId`, `Name`, `Parent`, `PredictionMode`, `PropertyStatusStudio`, `RobloxLocked`, `SerializedOverrides`, `SourceAssetId`, `Tags`, `UniqueId`, `numExpectedDirectChildren`, `DataCost`, `Capabilities`, `DefinesCapabilities`, `IsInSandbox`, `Sandboxed`, `AddTag`, `ClearAllChildren`, `Clone`, `Destroy`, `FindFirstAncestor`, `FindFirstAncestorOfClass`, `FindFirstAncestorWhichIsA`, `FindFirstChild`, `FindFirstChildOfClass`, `FindFirstChildWhichIsA`, `FindFirstDescendant`, `GetActor`, `GetAttribute`, `GetAttributeChangedSignal`, `GetAttributes`, `GetChildren`, `GetDebugId`, `GetDescendants`, `GetFullName`, `GetStyled`, `GetStyledPropertyChangedSignal`, `GetTags`, `HasTag`, `IsAncestorOf`, `IsDescendantOf`, `IsPropertyModified`, `QueryDescendants`, `RemoveTag`, `ResetPropertyToDefault`, `SetAttribute`, `WaitForChild`, `Remove`, `children`, `clone`, `destroy`, `findFirstChild`, `getChildren`, `isDescendantOf`, `remove`, `AncestryChanged`, `AttributeChanged`, `ChildAdded`, `ChildRemoved`, `DescendantAdded`, `DescendantRemoving`, `Destroying`, `StyledPropertiesChanged`, `childAdded`
- From [Object](https://rapi.sleaze.dev/classes/Object.md): `ClassName`, `className`, `GetPropertyChangedSignal`, `IsA`, `isA`, `Changed`
