Class Shimmer
A text element that brightens and dims on a slow loop to show that work is still in progress.
Inheritance
Implements
Inherited Members
Namespace: Unity.AppUI.UI
Assembly: Unity.AppUI.dll
Syntax
[UxmlElement]
public class Shimmer : LocalizedTextElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IVisualElementScheduler, IBindable, INotifyValueChanged<string>, ITextEdition, ITextElementExperimentalFeatures, IExperimentalFeatures, ITextSelection, IContextOverrideElement, IAdditionalDataHolder
Remarks
Use Shimmer for a surface that has no determinate progress to report and where a spinner would overstate it, for instance the verb of a streaming chat response. It is a LocalizedTextElement, so it drops in wherever a label already sits and keeps its localization and its inherited font.
The web implementation sweeps a gradient highlight through the glyphs with
background-clip: text. USS has neither gradient backgrounds on text nor keyframe
animations, so the UITK port keeps the intent rather than the mechanism: the text color travels
between its resting value and --shimmer-highlight-color on the same two second loop. The
driver is a scheduled item, the way Skeleton drives its pulse.
Both ends of the loop come from the stylesheet: --shimmer-base-color is the resting
colour and also what the element paints when it is not looping, and
--shimmer-highlight-color is the peak. Restyle a Shimmer by overriding those, not
color. Stopping the loop restores the resting colour rather than leaving it wherever
the last frame put it. Set active to false for static text, for instance when
honouring a reduced motion preference.
The two second period is deliberately off the motion token scale, whose durations top out at 500ms because they size discrete transitions. A continuous ambient loop at that speed reads as a flicker.
Examples
A label that shimmers while a response streams in.
var status = new Shimmer { text = "Thinking" };
parentElement.Add(status);
// Once the work is done, settle it into static text.
status.active = false;
Static from the start.
<appui:Shimmer text="Thinking" active="false" />
Constructors
Shimmer()
Default constructor.
Declaration
public Shimmer()
Shimmer(string)
Construct a Shimmer with the given text.
Declaration
public Shimmer(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The text to display. |
Fields
activeUssClassName
The styling class applied while the Shimmer is looping.
Declaration
public const string activeUssClassName = "appui-shimmer--active"
Field Value
| Type | Description |
|---|---|
| string |
ussClassName
The Shimmer main styling class.
Declaration
public const string ussClassName = "appui-shimmer"
Field Value
| Type | Description |
|---|---|
| string |
Properties
active
Whether the text loops between its resting color and the highlight. True by default.
Declaration
[CreateProperty]
[UxmlAttribute]
public bool active { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
Setting this to false stops the driver and restores the resting color.