Skip to content

Card Animations

LCARdS cards support anime.js-powered animations triggered by user interactions or entity state changes. Each card can have multiple animations with different triggers.

anime.js v4

LCARdS uses anime.js v4, which has a different API from v3. Key differences users should know:

  • The ease property uses v4 naming convention: inOutQuad, outElastic, inOutSine (no ease prefix). v3-style names like easeInOutQuad are passed through as-is and may work, but v4 names are preferred.
  • The easing property from v3 is not supported — always use ease.
  • Spring physics: { type: 'spring', params: { stiffness: 150, damping: 20 } } syntax is the same.

Basic Structure

Animations are defined in a card's animations array:

yaml
animations:
  - id: tap-pulse           # Optional identifier
    trigger: on_tap
    preset: pulse
  - trigger: on_entity_change
    preset: glow
    entity: binary_sensor.motion
    to_state: "on"
    params:
      color: "{theme:colors.alert.red}"

Triggers

TriggerWhen it fires
on_tapCard is tapped or clicked
on_holdLong-press on the card
on_hoverMouse enters the card
on_leaveMouse leaves the card
on_loadCard is rendered on page load
on_entity_changeA watched entity changes state

Animation Options

OptionTypeDefaultDescription
triggerstringWhen to run (required)
presetstringAnimation preset name (required)
idstringOptional identifier for this animation — alphanumeric, hyphens, and underscores only
enabledbooleantrueSet to false to disable without removing
durationnumberpreset defaultDuration in ms (0–10 000)
delaynumber0Delay before starting (ms)
loopboolean / numberpreset defaulttrue = infinite loop, false = once, number = iteration count
alternatebooleanpreset defaultReverse direction on each loop
easestring / objectpreset defaultEasing function — see below
paramsobjectPreset-specific parameters — see preset tables
targetstringCSS selector or data-field-id attribute to restrict which element animates
entitystringcard entityEntity to watch (for on_entity_change)
from_statestringOnly fire when transitioning FROM this state
to_statestringOnly fire when transitioning TO this state
check_on_loadbooleanfalseCheck entity state immediately on load and fire if it matches to_state

Motion Presets

pulse

Scale and brightness breathing effect.

ParamDefaultDescription
max_scale1.15Peak scale factor (alias: scale)
max_brightness1.4Peak brightness (1.0 = normal)
duration1200ms per cycle
easeeaseInOutSineEasing function
looptrueLoop continuously
alternatetrueReverse on each loop

glow

Animated drop-shadow bloom.

ParamDefaultDescription
colorvar(--lcars-blue)Glow colour (alias: glow_color)
blur_min0Minimum shadow blur (px)
blur_max10Maximum shadow blur (px)
duration1500ms per cycle
easeeaseInOutSineEasing function
looptrueLoop continuously
alternatetrueReverse on each loop

shake

Horizontal vibrate effect.

ParamDefaultDescription
intensity10Max displacement in px
duration500Total duration (ms)
frequency4Number of side-to-side shakes
easeeaseInOutSineEasing function
loopfalseLoop continuously

bounce

Elastic scale bounce.

ParamDefaultDescription
scale_max1.2Peak scale factor
duration800Duration (ms)
bounces3Number of bounces
easeeaseOutElasticEasing function
loopfalseLoop continuously
alternatefalseReverse on each loop

rotate

Rotation animation.

ParamDefaultDescription
from0Starting angle (degrees)
to360Ending angle (degrees)
directionShorthand: clockwise (0→360) or counterclockwise (0→−360)
duration1000Duration (ms)
easelinearEasing function
loopfalseLoop continuously
alternatefalseReverse on each loop

Slow opacity blink.

ParamDefaultDescription
max_opacity1.0Peak opacity
min_opacity0.3Trough opacity
duration1200ms per half-cycle
easelinearEasing function
looptrueLoop continuously
alternatetrueReverse on each loop

strobe

Rapid opacity flicker.

ParamDefaultDescription
max_opacity1.0Peak opacity
min_opacity0Trough opacity
duration100ms per half-cycle
easelinearEasing function
looptrueLoop continuously
alternatetrueReverse on each loop

fade

Simple opacity transition.

ParamDefaultDescription
from1Starting opacity
to0.3Target opacity
duration1000Duration (ms)
easelinearEasing function
loopfalseLoop continuously
alternatefalseReverse on each loop

slide

Slide in from a direction.

ParamDefaultDescription
fromrightEntry direction: up, down, left, right (alias: direction)
distance100Distance in px (or % string)
duration500Duration (ms)

scale

Simple scale transform animation. Ideal for button feedback.

ParamDefaultDescription
scale1.1Target scale factor
from1Starting scale
duration200Duration (ms)
easeoutQuadEasing function
loopfalseLoop continuously

scale-reset

Returns an element to its original scale (1.0). Pair with on_leave to reset hover effects.

ParamDefaultDescription
duration200Duration (ms)
easeoutQuadEasing function
yaml
# Typical hover + reset pair
animations:
  - preset: scale
    trigger: on_hover
    params:
      scale: 1.1
  - preset: scale-reset
    trigger: on_leave

Text Animation Presets

Target individual text elements with target: "[data-field-id='my-field']".

text-reveal

Characters/words/lines appear in sequence with a stagger.

ParamDefaultDescription
splitcharsSplit unit: chars, words, or lines
stagger50Delay between units (ms)
duration800Duration per unit (ms)
from_opacity0Starting opacity of each unit
from_y20Starting Y offset (px)
loopfalseLoop continuously

text-scramble

Matrix-style character scramble before settling on the real text.

ParamDefaultDescription
duration800ms each character spends scrambling
stagger40Delay between characters starting (ms)
delay0Initial delay before animation starts (ms)
settle_at0.85Fraction (0–1) of duration spent scrambling
charactersA-Z 0-9 !@#$%^&*Pool of random characters to cycle through
loopfalseLoop continuously

text-glitch

Rapid position and opacity jitter for a glitch/malfunction effect.

ParamDefaultDescription
intensity5Max displacement in px / SVG units
duration300ms per glitch cycle
stagger50Delay between characters (ms)
loopfalseLoop continuously

text-typewriter

Characters appear one at a time at a fixed speed.

ParamDefaultDescription
speed100ms per character
loopfalseLoop continuously

Visual Effect Presets

shimmer

Fill colour and opacity animation for shimmering effects.

ParamDefaultDescription
color_fromcurrent fillStarting colour
color_toTarget colour (required; alias: shimmer_color)
opacity_from1Starting opacity
opacity_to0.5Ending opacity
duration1500Duration (ms)
easeinOutSineEasing function
looptrueLoop continuously
alternatetrueReverse on each loop

flicker

Randomised opacity animation for flickering effects.

ParamDefaultDescription
max_opacity1Maximum opacity
min_opacity0.3Minimum opacity
duration1000Duration (ms)
easelinearEasing function
looptrueLoop continuously

cascade

Staggered animation for multiple target elements.

ParamDefaultDescription
stagger100Delay between elements (ms)
propertyopacityProperty to animate
from0Starting value
to1Ending value
duration1000Duration (ms)
easeoutExpoEasing function
loopfalseLoop continuously

ripple

Expanding scale with opacity fade.

ParamDefaultDescription
scale_max1.5Maximum scale
opacity_min0Minimum opacity at peak
duration1000Duration (ms)
easeoutExpoEasing function
loopfalseLoop continuously

SVG-Specific Presets

draw

SVG path drawing animation using strokeDashoffset. Apply to <path> elements.

ParamDefaultDescription
reversefalseDraw in reverse direction
duration2000Duration (ms)
easelinearEasing function
loopfalseLoop continuously

march

CSS-based marching dashed line animation. More performant than JS for continuous animations.

ParamDefaultDescription
dash_length10Length of each dash
gap_length5Gap between dashes
speed2Seconds per cycle
directionforwardforward or reverse

Utility Presets

set

Immediately sets properties without animation. Useful for establishing initial state before other animations.

ParamDefaultDescription
propertiesObject with CSS properties to set
yaml
animations:
  - preset: set
    trigger: on_load
    params:
      properties:
        opacity: 0.5
        fill: red

motionpath

Path-following animation (requires a <path> element in the SVG).

ParamDefaultDescription
path_selectorCSS selector for path element (required)
duration4000Duration (ms)
easelinearEasing function
looptrueLoop continuously

Easing Functions

LCARdS uses anime.js v4 easing names (without the ease prefix used in v3):

yaml
ease: "inOutQuad"       # Standard in-out (v4) — was easeInOutQuad in v3
ease: "outElastic"      # Elastic bounce out
ease: "inOutSine"       # Smooth sine curve
ease: "linear"          # Constant speed
ease:                    # Spring physics
  type: spring
  params:
    stiffness: 150
    damping: 20

Common easing names (v4):

CategoryNames
QuadinQuad, outQuad, inOutQuad
CubicinCubic, outCubic, inOutCubic
SineinSine, outSine, inOutSine
ExpoinExpo, outExpo, inOutExpo
ElasticinElastic, outElastic, inOutElastic
BackinBack, outBack, inOutBack
BounceinBounce, outBounce, inOutBounce
Otherlinear, steps(N)

Comprehensive Example

A button showing: load animation, tap feedback, hover glow, entity change with state filter, and a text scramble targeted to a specific field.

yaml
type: custom:lcards-button
entity: light.workbench
preset: lozenge
text:
  label:
    content: Workbench
    position: top-left
  state:
    content: "{entity.state}"
    position: center

animations:
  # Entrance animation — runs once on load
  - trigger: on_load
    preset: fade
    params:
      from: 0
      to: 1
    duration: 800

  # Tap feedback — quick bounce
  - trigger: on_tap
    preset: bounce
    params:
      scale_max: 1.08
      bounces: 2
    duration: 400

  # Hover glow — looping while mouse is over
  - trigger: on_hover
    preset: glow
    params:
      color: "var(--lcards-orange)"
      blur_max: 12

  # Entity turns on — pulse with scramble on the state label
  - trigger: on_entity_change
    entity: light.workbench
    to_state: "on"
    check_on_load: true
    preset: pulse
    params:
      max_scale: 1.05
      duration: 1000
    loop: true

  # Entity turns off — stop loop by playing once in reverse
  - trigger: on_entity_change
    entity: light.workbench
    to_state: "off"
    preset: fade
    params:
      from: 1
      to: 0.7
    duration: 300
    loop: 1
    alternate: true