USS transition
Understand the USS transition properties, their syntax, and accepted values.
Read time 11 minutesLast updated 25 days ago
USS transitions are similar to CSS transitions. A USS transition changes property values over a given duration. You can use a USS transition to create an animation that changes the appearance of a visual element. For example, you can use a UI transition to make UI elements that change size or color when a user hovers their cursor over them.
You can use the controls in the UI Builder, a USS file, or a C# script to set the transition properties for a visual element.
The following table lists the transition properties and their corresponding C# methods:
Property | C# method | Description |
|---|---|---|
| | Which USS properties the transition applies to. |
| | How long the transition takes to complete. |
| | How the property moves between values over time. |
| | When the transition starts. |
| Shorthand for |
Starting of a transition
A transition triggers if you set a transition duration on the style and the style value changes. You can use pseudo-classes, C# methods, or events to trigger the transition.
The following transition example changes the color and rotation of the label when you hover over it. The transition has a duration of 2 seconds.

A transition example
To implement this example, do the following:
- Set the transition properties for the visual element.
- Set the transition duration.
- Set the start and end style values.
The example USS looks like this:
/* Set the transition properties, duration, and start style values. */.labelClass { transition-property: color, rotate; transition-duration: 2s; color: black;}/* The Label:hover triggers the transition. Set the end values for the trigger. */.labelClass:hover { rotate: 10deg; color: red;}
To learn how to trigger a transition with C# events, refer to Create a simple transition with UI Builder and C# scripts.
Match the value units
For properties that you set with a value and unit, make sure the units match. Pay special attention to transitions to or from default values. For example, the default value of the attribute is . If you try to transition from this value to a percentage value, the transition doesn't work.
translate0pxThe following transition example offsets the visual element to the left by over 2 seconds. The default value of the property is . You must explicitly set the unit to for the transition to work.
50pxleftauto0px
An offset to left transition example
The example USS looks like this:
.boxClass:hover { left: 50px;}.boxClass { transition-property: left; transition-duration: 2s; transition-timing-function: ease-in-out-sine; left: 0px;}
Transitions for an inherited property
For visual elements in a hierarchy, USS transitions behave the same as CSS transitions. If you set transitions for an inherited property, such as , transitions applied to the parent elements cascade to the child elements. To find out which property is inherited, refer to USS property reference.
colorInterrupt transitions
When an incomplete transition is , USS transitions behave the same as CSS transitions. The reverse transition might be faster. For more information, refer to Faster reversing of interrupted transitions
interruptedSameTransition events
Transition events are generated by transitions. You can use them to detect when a transition starts and ends. For an example, refer to Create a transition event.
Usage hints
The Usage Hints offers a set of properties for optimizations. You can use it to reduce draw calls and geometry regeneration.
Transition controls in the UI Builder
You can use the controls in the Transition Animations section of the in the UI Builder to set transition rules for a visual element. You can set multiple transitions on a visual element. To add another transition, select Add Transition. To remove a transition, select the Remove (−) button.
Inspector
?

This transition causes a visual element to adjust its scale over 500 milliseconds in a linear fashion after a delay of 20 milliseconds.
Transition property
The transition property defines which USS properties the transition applies to.
Keywords
The transition property supports the following keywords:
- : Applies transitions to all properties and overrides any preceding transitions. This is the default value.
all - : Applies transitions to all properties.
initial - : Ignores transitions for all properties.
none - : Ignores transitions for the specified duration, delay, and easing function.
ignored
Animatability
You can apply transitions to most USS properties. However, the animatability for certain properties is different. The animatability of USS properties falls into the following categories:
- Fully animatable: Supports transition from the start value to the end value, at a speed that follows the easing function and transition duration.
- Discrete: Supports transition between values in a single step from the start value to the end value.
- Non-animatable: Doesn't support transition.
To find out the animatability of each property, see USS property reference.
USS examples
You can supply a single USS property, a keyword, or a comma-separated list of them to .
transition-propertytransition-property: scale;transition-property: translate, all, rotate;transition-property: initial;transition-property: none;
C# examples
The property is of type . is a struct that you can construct from a string. is a struct you can construct from a list of .
IStyle.transitionPropertyStyleList<StylePropertyName>StylePropertyNameStyleListStylePropertyName//Create a list that contains the rotate property, and use it to set transitionProperty.List<StylePropertyName> properties = new List<StylePropertyName>();properties.Add(new StylePropertyName("rotate"));//Given a VisualElement named "element"...element.style.transitionProperty = new StyleList<StylePropertyName>(properties);
You can use implicit conversions to simplify the above code as follows:
//Given a VisualElement named "element"...element.style.transitionProperty = new List<StylePropertyName> { "rotate" };
Transition duration
The transition duration sets how long the transition takes to complete.
Keywords
The transition duration supports the following keywords:
- : Sets the duration to
initial. This is the default value.0s
USS examples
You can supply a number with a unit, a keyword, or a comma-separated list of numbers and units to .
transition-durationtransition-duration: 2s;transition-duration: 800ms;transition-duration: 3s, 1500ms, 1.75s;transition-duration: initial;
If you supply multiple values, each value applies to the corresponding property specified in . In the following example, the original duration for scale is , but overrides it to .
transition-property1sall2stransition-property: scale, all, rotate;transition-duration: 1s, 2s, 3s;
C# examples
The property is of type . is a struct that you can construct from a number and a enum. is a struct you can construct from a list of .
IStyle.transitionDurationStyleList<TimeValue>TimeValueTimeUnitStyleListTimeValue//Create a list that contains durations 2s and 500ms and use it to set transitionDuration.List<TimeValue> durations = new List<TimeValue>();durations.Add(new TimeValue(2f, TimeUnit.Second));durations.Add(new TimeValue(500f, TimeUnit.Millisecond));//Given a VisualElement named "element"...element.style.transitionDuration = new StyleList<TimeValue>(durations);
You can use implicit conversions to simplify the above code as follows:
//Given a VisualElement named "element"...element.style.transitionDuration = new List<TimeValue> { 2, new (500, TimeUnit.Millisecond) };
Transition timing function
The transition timing function sets how the property moves between values over time.
Keywords
The transition timing function supports the following keywords. The default value is , which sets the easing function to .
initialeaseinitialeaseease-inease-outease-in-outlinearease-in-sineease-out-sineease-in-out-sineease-in-cubicease-out-cubicease-in-out-cubicease-in-circease-out-circease-in-out-circease-in-elasticease-out-elasticease-in-out-elasticease-in-backease-out-backease-in-out-backease-in-bounceease-out-bounceease-in-out-bounce
For detailed information about each function, refer to MDN's documentation for the CSS attribute or easings.net.
transition-timing-functionUSS examples
You can supply an easing function, a keyword, or a comma-separated list of easing functions to .
transition-timing-functiontransition-timing-function: linear;transition-timing-function: ease-in, ease-out-circ, ease-in-out-cubic;transition-timing-function: initial;
C# examples
The property is of type . is a struct that you can construct from an enum.
IStyle.transitionTimingFunctionStyleList<EasingFunction>EasingFunctionEasingMode//Create a list that contains the Linear easing function, and use it to set transitionTimingFunction.List<EasingFunction> easingFunctions = new List<EasingFunction>();easingFunctions.Add(new EasingFunction(EasingMode.Linear));//Given a VisualElement named "element"...element.style.transitionTimingFunction = new StyleList<EasingFunction>(easingFunctions);
You can use implicit conversions to simplify the above code as follows:
//Given a VisualElement named "element"...element.style.transitionTimingFunction = new List<EasingFunction> { EasingMode.Linear };
Transition delay
The transition delay sets when the transition starts.
Keywords
The transition delay supports the following keywords:
- : Sets the delay to
initial. This is the default value.0s
USS examples
You can supply a number with a unit, a keyword, or a comma-separated list of numbers and units to .
transition-delaytransition-delay: 0s;transition-delay: 300ms;transition-delay: 2s, 650ms, 2.75s;transition-delay: initial;
C# examples
The property is of type . is a struct that you can construct from a number and a enum. is a struct you can construct from a list of .
IStyle.transitionDelayStyleList<TimeValue>TimeValueTimeUnitStyleListTimeValue//Create a list that contains delays 0.5s and 200ms, and use it to set transitionDelay.List<TimeValue> delays = new List<TimeValue>();delays.Add(new TimeValue(0.5f, TimeUnit.Second));delays.Add(new TimeValue(200f, TimeUnit.Millisecond));//Given a VisualElement named "element"...element.style.transitionDelay = new StyleList<TimeValue>(delays);
You can use implicit conversions to simplify the above code as follows:
//Given a VisualElement named "element"...element.style.transitionDelay = new List<TimeValue> { 0.5f, new(200, TimeUnit.Millisecond) };
USS transition
transitionYou can supply one transition, a keyword, or a comma-separated list of transitions to . You separate properties within a transition by a space in the following order:
transitiontransition-propertytransition-delaytransition-durationtransition-timing-function
Keywords
transitioninitial- :
transition-delay0s - :
transition-duration0s - :
transition-propertyall - :
transition-timing-functionease
USS examples
/*One transition*/transition: width 2s ease-out;/*Two transitions*/transition: margin-right 4s, color 1s;
Transition on multiple property examples
This section includes examples that apply transitions on multiple properties.
Example 1
This example applies transitions on the and properties:
scaletransform-origin- The first transition is on the property. It has a duration of
scale, a delay of4s, and the0seasing function.ease-in-sine - The second transition is on the property. It has a duration of
transform-origin, a delay of3s, and the600mseasing function.ease-out-elastic
.classA { transition-property: scale, transform-origin; transition-duration: 4s, 3s; transition-delay: 0s, 600ms; transition-timing-function: ease-in-sine, ease-out-elastic;}
Example 2
In this example, the later transitions override earlier transitions, including transitions with the keyword:
all- The first transition is on all properties. It applies a duration of 500 milliseconds, a delay of zero seconds, and the easing function.
linear - The second transition is on the property. It overrides the transition with a duration of
translate, a delay of1s, and the1seasing function. All other properties still have a duration ofease-in, a delay of500ms, and the0seasing function.linear
.classB { transition-property: all, translate; transition-duration: 500ms, 1s; transition-delay: 0s, 1s; transition-timing-function: linear, ease-in;}
Example 3
This example shows what happens when property value lists are of different lengths. If any property's list of values is shorter than that for , Unity repeats its values to make them match. Similarly, if any property's value list is longer than , Unity truncates it.
transition-propertytransition-property.classC { transition-property: scale, rotate, translate; transition-duration: 1s, 2s; transition-delay: 1s, 2s, 3s, 4s, 5s, 6s, 7s;}
The following table shows the final results for the example above:
Property | Duration | Delay | Easing function |
|---|---|---|---|
| | | |
| | | |
| | | |
Additional resources
- Use usage hints to reduce draw calls and geometry regeneration
- Using CSS transitions (Mozilla developer documentation)
- CSS transition (Mozilla developer documentation)
- CSS transition-property (Mozilla developer documentation)
- CSS transition-duration property (Mozilla developer documentation)
- CSS transition-timing-function property (Mozilla developer documentation)
- CSS transition-delay property (Mozilla developer documentation)