UI Toolbox logoUI Toolbox
Support

AnimatedLabel

An AnimatedLabel is a Label that colors, highlights and moves parts of its text. An effect tag in the text marks a part, as a rich text tag does.

The label Text Animation with the letters of Animation in a purple to pink gradient, and the hint Press any key below itThe label Text Animation with the letters of Animation in a purple to pink gradient, and the hint Press any key below it

<UIToolbox.AnimatedLabel
    text="Text &lt;gradient&gt;Animation&lt;/gradient&gt;" />
<UIToolbox.AnimatedLabel text="Level up" effect="Wave, Rainbow" />
title.text = "Text <gradient>Animation</gradient>";
loot.text = "You found a "
    + "<gradient=#ffd60a,#ff9f0a><wave>LEGENDARY</wave></gradient>"
    + " sword";
hint.text = "Press <highlight>Space</highlight> to jump";
health.text = "<pulse>Low health</pulse>";
health.Playing = false; // stops the effects at the current moment

Effect tags

Tag Effect
<gradient> A color blend from the start of the part to its end. The blend moves along the text. <gradient=#from,#to> gives the two colors.
<rainbow> All hues along the text. The hues move.
<wave> The glyphs move up and down, one after the other.
<shake> Each glyph shakes on its own.
<pulse> The text fades out and in.
<shimmer> or <shine> A light band moves across the label.
<highlight> A colored rectangle behind the text, as from a marker pen. <highlight=#color> gives the color. It does not move.
<pop> Each glyph grows and shrinks back around its center, one glyph after the other, as a wave moves them.
<grow> The whole part grows and shrinks back as one block around its center, as on a beat.
<jitter> Each glyph takes a small offset and turn that change about 8 times a second: a hand-drawn, stop-motion look.

Members

Member Description
text The text with the effect tags.
DisplayText The text that the label draws: text without the effect tags.
Effect (effect) The effects of the whole text, a set of TextEffects values: Gradient, Rainbow, Wave, Shake, Pulse, Shimmer, Highlight, Pop, Grow, Jitter. The effect tags add to them.
Speed (speed) The speed of all effects (1). Zero stops the movement and keeps the colors.
Playing (playing) False stops the effects at the current moment (true).
Amplitude (amplitude) The distance in pixels that a glyph moves in a wave, a shake, a pop, a grow or a jitter (4).
GradientFrom, GradientTo The colors of a gradient that has no colors in its tag. A value set in code replaces the USS variable.
HighlightColor The color of a highlight that has no color in its tag. A value set in code replaces the USS variable.
IsAnimating True while the label changes its glyphs each frame: it shows, it has an effect that moves, Playing is true and Speed is not zero.
WithoutEffectTags(text) Static. Returns the text without its effect tags, as the label draws it. Rich text tags stay. Use it for a plain label, or for a name that a player types. Call it on the main thread.

In the examples

Styling

Class or variable Element
tb-animated-label The label: --tb-color-text, and the text wraps.
--tb-animated-label-gradient-from The first color of a gradient (#FF2D55).
--tb-animated-label-gradient-to The last color of a gradient (#7B2FF7).
--tb-animated-label-highlight The color of a highlight (rgba(255, 214, 10, 0.35)).
.quest-title {
    --tb-animated-label-gradient-from: #ffd60a;
    --tb-animated-label-gradient-to: #ff9f0a;
}

A theme sets the variables on :root or on the root of the panel. The variables inherit, so they reach every label. A rule on .tb-animated-label does not reach a Badge or the title of a Card, because they do not have that class.

The DirectorDemo scene shows the titles of a video in an AnimatedLabel. Each title item on a Timeline sets the text and the effects. See Video director.