Card Animations
Animations make a card move: a pulse when you tap it, a glow while a light is on, a slide-in when a view opens. Every LCARdS card takes an animations list. Each entry names a preset (what moves) and a trigger (when it plays).
- A card can have as many entries as you like, each with its own trigger. An entry without
triggerplays when the card loads. - Each preset has its own duration, easing and looping; set
duration,looporeaseon the entry to change them. - When the device asks for less motion, animations jump to their end or stay still: see Reduced motion.
Try it
- The button and elbow editors have an animation editor on the Effects tab, with a field for every option on these pages; the data grid and MSD studios have one too.
- Every example here is live: tap the cards.
| Page | Covers |
|---|---|
| Triggers | Taps, holds, hover, on load, entrances with on_show, data source changes |
| Entity Change Triggers | Play on a state change, loop while a condition holds, follow an attribute |
| Timing and Easing | Duration, delay, loops, numbers that follow an entity (map_range), easing, reduced motion |
| Rule-based Animations | Animate many cards at once from a rule |
| Preset Reference | Every built-in preset and its params |
Quick start
Two entries to start from: a bounce on every tap, and a pulse that runs while the light is on. Tap the card to switch the light and watch the pulse start and stop.
paramsholds the preset's own settings, here how far the pulse grows. The Preset Reference lists them for each preset.
type: custom:lcards-button
entity: light.workbench
preset: lozenge
text:
name:
show: true
tap_action:
action: toggle
animations:
# a quick bounce on every tap
- trigger: on_tap
preset: bounce
duration: 400
params:
scale_max: 1.08
bounces: 2
# a pulse while the light is on
- trigger: on_entity_change
entity: light.workbench
preset: pulse
loop: true
while:
state: "on"
params:
max_scale: 1.05Available presets
preset picks what the animation does. Each name links to its parameters and defaults in the Preset Reference.
| Category | Presets |
|---|---|
| Motion | bounce, blink, fade, glow, pulse, rotate, scale, scale-reset, shake, skew, slide, strobe |
| Colour | cascade-color, color-shift, shimmer |
| Text | text-glitch, text-reveal, text-decode, text-scramble, text-typewriter |
| Visual effects | cascade, flicker, glitch, ripple |
| SVG | draw, march, morph |
| Stagger | stagger-grid, stagger-wave, stagger-radial, stagger-flash, tap-ripple |
| Effects | boot-sequence, sensor-sweep |
| Timeline | timeline-cascade, timeline-attention, sequence |
| Advanced | chaos, physics-spring |
| Utility | motionpath, set, custom |
Targets
Without a target an animation moves the whole card; target or targets picks parts of it, such as one text field. Use it to scramble just the label, or blink just the state.
- The selector is a CSS selector looked for inside the card. Text fields carry
data-field-idwith their name, so[data-field-id='name']is the name text. targetanimates every element the selector matches;targetstakes a list of selectors and animates the first match of each.target: backgroundanimates the card's background animations instead of its elements;effectpicks one of them.
type: custom:lcards-button
entity: light.workbench
preset: lozenge
text:
name:
show: true
state:
show: true
content: "{entity.state}"
position: center
tap_action:
action: toggle
animations:
# only the state text blinks when you tap
- trigger: on_tap
preset: blink
target: "[data-field-id='state']"
loop: 3
duration: 200More about targets
- A selector that matches nothing: the animation still plays, on the whole card, with a warning in the browser console.
- SVG elements with their own transform: an element with its own
transform(common in SVGs exported from Inkscape, such as MSD base images) keeps it, so it stays exactly where it was drawn. Ascale,rotateorpulseanimation on a rotated or scaled group then turns about a point slightly off the group's centre. Colour, opacity, stroke and draw animations are not affected. - MSD overlays: on an MSD, a line or shape picks its drawn part by itself; see MSD Animations and Rules.
| Key | Type | Default | Description |
|---|---|---|---|
target | string | the whole card | CSS selector for the elements to animate, or background for the card's background animations |
targets | string / list | - | One or more CSS selectors; the first element each one matches is animated |
effect | number | every effect | With target: background: the index of the background_animation entry to animate (0 is the first, the bottom layer) |
Putting it together
One button with an entrance, tap feedback, a hover glow and two entity animations. Hover over it with a mouse, tap it, and watch the light switch on and off.
type: custom:lcards-button
entity: light.workbench
preset: lozenge
text:
label:
show: true
content: Workbench
position: top-left
state:
show: true
content: "{entity.state}"
position: center
tap_action:
action: toggle
animations:
# entrance: fades in once when the card loads
- trigger: on_load
preset: fade
duration: 800
params:
from: 0
to: 1
# tap feedback: a quick bounce
- trigger: on_tap
preset: bounce
duration: 400
params:
scale_max: 1.08
bounces: 2
# hover: glows while the mouse is over the card
- trigger: on_hover
preset: glow
params:
color: var(--lcars-orange)
blur_max: 12
# pulses while the light is on
- trigger: on_entity_change
entity: light.workbench
preset: pulse
loop: true
while:
state: "on"
params:
max_scale: 1.05
# dims and comes back once when the light turns off
- trigger: on_entity_change
entity: light.workbench
to_state: "off"
preset: fade
duration: 300
loop: 1
alternate: true
params:
from: 1
to: 0.7Animation options
Every key an animation entry takes, on every LCARdS card. The same entries go in an MSD's animations lists; a rule's apply.animations takes a smaller set (Rule-based Animations).
duration,delay,loop,alternateandeasecan also sit insideparams; the entry's own key wins when both are set.
type: custom:lcards-button
preset: lozenge
text:
name:
content: Options
show: true
animations:
- id: tap-glow
trigger: on_tap
preset: glow
duration: 600
delay: 100
loop: 2
alternate: true
ease: inOutSine
params:
color: var(--lcars-yellow)More about animation options
- Unrecognised keys warn, they don't block. A key the animation or its
paramsdoesn't know (a leftover from switchingpreset, say) gives a console warning but never stops the card loading. Only a wrong type on a key it does know (duration: fast) is an error. Clear leftovers anyway: some presets readparamsdifferently depending on what else is there.
| Key | Type | Default | Description |
|---|---|---|---|
preset | string | required | What the animation does: see Available presets |
trigger | string | on_load | When it plays: see Triggers |
params | object | the preset's defaults | The preset's own settings: see the Preset Reference. Each value may be a map_range |
id | string | - | A name for the entry, for debugging: letters, digits, - and _ |
enabled | boolean | true | false keeps the entry but never plays it |
duration | number / object | the preset's | Length of one play, ms, or a map_range: see Timing |
delay | number / object | 0 | Wait before it starts, ms, or a map_range |
loop | boolean / number | the preset's | true repeats for ever, false plays once, a number repeats that many more times |
alternate | boolean | the preset's | Play every other repeat backwards |
ease | string / object | the preset's | The easing curve: see Easing |
essential_motion | boolean | false | Keep playing when the device asks for reduced motion: see Reduced motion |
target | string | the whole card | What to animate: see Targets |
targets | string / list | - | Several things to animate: see Targets |
effect | number | every effect | With target: background: which background animation |
entity | string | - | on_entity_change: the entity to watch: see Entity Change Triggers |
attribute | string | the state | on_entity_change: an attribute to watch instead of the state; brightness_pct gives a light's brightness as 0–100 |
from_state | string | - | on_entity_change: play only when the value changes from this |
to_state | string | - | on_entity_change: play only when the value changes to this |
while | object | - | on_entity_change: play while this holds and stop when it no longer does: see while |
check_on_load | boolean | true | on_entity_change: also check the entity when the card loads |
datasource | string | - | on_datasource_change: the data source to watch: see on_datasource_change |