Triggers
trigger on an animation entry says when it plays. This page covers every trigger except on_entity_change, which has its own page: Entity Change Triggers.
trigger
One trigger per entry; give a card several entries to react to several things. Leave trigger out and the entry plays when the card loads.
on_state_change,on_redrawandon_exitare not triggers (the config checker rejects them, and they never fire). For state changes useon_entity_change.
type: custom:lcards-button
preset: lozenge
text:
name:
content: Triggers
show: true
animations:
# once when the card loads
- trigger: on_load
preset: fade
params:
from: 0
to: 1
# on every tap
- trigger: on_tap
preset: bounce
# on a long press
- trigger: on_hold
preset: shake| Trigger | Plays |
|---|---|
on_load | Once, when the card first renders |
on_show | Each time the card appears: when its view opens, when a visibility condition shows it, or when you come back from another view |
on_tap | When the card is tapped or clicked |
on_double_tap | When the card is double-tapped |
on_hold | On a long press |
on_hover | While the mouse is over the card |
on_leave | When the mouse leaves the card |
on_entity_change | When a watched entity changes: see Entity Change Triggers |
on_datasource_change | When a data source updates: see on_datasource_change |
| Key | Type | Default | Description |
|---|---|---|---|
trigger | string | on_load | When the entry plays: one of the triggers above |
Taps and holds
on_tap, on_double_tap and on_hold play when you touch the card, alongside its tap, double-tap and hold actions. Use them for feedback that the press landed.
- The animation and the action both happen: a tap that toggles a light also plays the
on_tapanimation. - On a slider, tap and hold animations sit on its border caps, where the actions are. On a data grid a tap anywhere on the grid plays them, and
tap-ripplestarts from the tap point.
type: custom:lcards-button
entity: light.workbench
preset: lozenge
text:
name:
show: true
tap_action:
action: toggle
hold_action:
action: more-info
animations:
# grows and shrinks back once
- trigger: on_tap
preset: pulse
loop: 1
duration: 200
- trigger: on_hold
preset: shake| Key | Type | Default | Description |
|---|---|---|---|
trigger | string | on_load | on_tap, on_double_tap or on_hold |
Hover
on_hover plays while the mouse is over the card, and on_leave when it moves off. A looping hover animation, such as a glow, stops as soon as the mouse leaves.
- Hover only works with a mouse or trackpad: on a touch screen these triggers never fire.
- Leaving the card first stops the
on_hoveranimations, then plays theon_leaveones.
type: custom:lcards-button
preset: lozenge
text:
name:
content: Hover me
show: true
animations:
# glows while the mouse is over the card
- trigger: on_hover
preset: glow
params:
color: var(--lcars-orange)
blur_max: 12
# a short fade when it leaves
- trigger: on_leave
preset: fade
duration: 300
loop: 1
alternate: true| Key | Type | Default | Description |
|---|---|---|---|
trigger | string | on_load | on_hover or on_leave |
Entrance animations with on_show
on_show plays each time the card is put on the page: when its view opens, when a visibility condition shows it, or when you come back from another view. Use it, not on_load, for entrance animations.
on_loadplays once per card. Home Assistant builds a card hidden by avisibilitycondition and only attaches it when the condition is met, so anon_loadanimation has already run, out of sight, by the time it appears.on_showdoes not play again while the card stays on the page: state changes and re-renders don't replay it.- Give several cards the same
on_showanimation with risingdelayvalues to build a view up piece by piece when it opens.
type: custom:lcards-button
preset: filled
text:
name:
content: Perimeter Armed
show: true
animations:
# slides in from the left and fades in, each time the card appears
- trigger: on_show
preset: slide
params:
from: left
distance: 120
duration: 600
- trigger: on_show
preset: fade
params:
from: 0
to: 1
duration: 600More about on_show
- With a visibility condition: add a
visibilitylist to the card (here, a condition onalarm_control_panel.homewithstate: armed_away) and the entrance plays every time the alarm is armed. The docs show the card without one. - A re-render while it plays: a card that re-renders just after it appears plays its entrance again from the start, so it is not cut short.
| Key | Type | Default | Description |
|---|---|---|---|
trigger | string | on_load | on_show plays each time the card appears; on_load once, when it first renders |
on_datasource_change
on_datasource_change plays each time a data source on the card gets a new value. Use it to flash a reading when it updates.
datasourcenames the source from the card'sdata_sources. The animation plays on every update, whatever the value.- The data source must exist when the card loads; one that doesn't is skipped with a warning in the browser console.
- Shown as the animation entry only: it needs a data source defined on the card.
animations:
- trigger: on_datasource_change
datasource: outdoor_temp
preset: blink
loop: 1| Key | Type | Default | Description |
|---|---|---|---|
datasource | string | required | The data source to watch, by name. A name with a dot (outdoor_temp.rolling_avg) still watches the whole source |