Animations¶
State-based animations apply styles to layout items when a configured entity reaches a specific state. The trigger is defined in the top-level animations: section; the target layout item is linked with animation_id.
This page shows the required YAML structure, the built-in animation names, and a complete state-based example.
Connect an animation to a layout item¶
Give the layout item an animation_id, then add a top-level animations: entry for the entity that triggers it:
entity.0 watches the first entry in entities:. When its state is on, the styles in animations: are applied to the circle with the same animation_id.
Do not put animations: inside a layout item.
The current state-animation target sections are lines, hlines, vlines, circles, arcs, rectangles, polygons, icons, names, areas, states, texts, and controls. Horseshoes and Sparklines are not targets of this animations: mechanism; use their own state/color configuration or a JavaScript template for dynamic behavior there.
For an icons target, you can also set icon in the matching animation target to change the displayed icon together with its styles.
Watch another configured entity¶
The number after entity. is the configured entity index. For example, entity.1 watches the second entity:
If an entity definition uses attribute, that selected attribute value is used for the state match.
Built-in animation names¶
The current card includes these animation names:
zoomOutbounceflashheadShakeheartBeatjellopulserubberBandshakeswingtadawobble
Use the name in the CSS animation style, together with the duration and any timing/repetition settings you need. zoomIn is not one of the built-in names in the current version.
Change several item types from one state¶
One state entry can update several layout sections. Each target uses its own animation_id:
Keep styles from the previous matching state¶
By default, a new matching animation target replaces the previous animation styles for that animation_id. Set reuse: true on an animation target when the new state should keep the previously applied animation styles and add its own styles.
Use a dynamic style instead¶
When the result depends on a number, calculation, or several entities rather than one exact state, put the condition directly in a supported style:
See JavaScript templates for dynamic values.