Actions
What a card does when you tap it, hold it or double-tap it: toggle a light, run any Home Assistant action, open a dashboard, a page or a dialog. Actions follow Home Assistant's own action model, so YAML from Home Assistant's cards works here too.
- A card takes up to three actions:
tap_action,hold_actionanddouble_tap_action. Each is an object whoseactionkey picks what happens. - The button, elbow, slider, select menu, data grid and astrometrics cards take actions; each card's page says where on the card they apply.
Quick start
A button that raises a red alert when tapped and clears it when held. Try it here: the alert recolours this page.
type: custom:lcards-button
preset: lozenge
text:
label:
content: RED ALERT
show: true
# tap: raise a red alert
tap_action:
action: perform-action
perform_action: lcards.red_alert
# hold: back to normal
hold_action:
action: perform-action
perform_action: lcards.clear_alertAction types
The action key picks what happens: toggle the entity, run an action, open a dashboard, a page or a dialog, or nothing.
togglepicks its service as Home Assistant's own cards do: fromoff,closedorlockedit turns the entity on, from any other state off.noneis how to stop a card's default: a button toggles its entity on a tap until itstap_actionsays otherwise.
type: custom:lcards-button
entity: input_boolean.lcards_test_lights
preset: lozenge
text:
name:
show: true
tap_action:
action: toggleaction | What it does |
|---|---|
toggle | Toggle the entity. Locks unlock and lock, covers and valves open and close, buttons are pressed, scenes are turned on |
perform-action | Run a Home Assistant action: name it in perform_action and give its data in data |
call-service | The older name for perform-action |
more-info | Open Home Assistant's more-info dialog for the entity |
navigate | Go to another dashboard or view (navigation_path) |
url | Open an address in a new browser tab (url_path) |
assist | Open Home Assistant's Assist dialog |
fire-dom-event | Fire Home Assistant's ll-custom event with the whole action, for integrations that listen for it such as browser_mod or Local Conditional Card. Add whatever keys the integration reads (browser_mod:, local_conditional_card:) |
fly-to, set-clock, set-model-scale, point-card | Move the camera, the scene date or the model size of an astrometrics card, or open a card on one of its points: see Scene actions and Opening cards from other cards |
none | Do nothing, in place of the card's default |
More about toggle
- Groups toggle through Home Assistant's
homeassistantdomain (homeassistant.turn_on,homeassistant.turn_off). - An entity with no state yet gets its domain's own
toggleaction (light.toggle).
Action keys
The keys of an action object, besides action: which entity it acts on, what to run, and where to go.
targetgoes to Home Assistant as the action's target, separate fromdata, as Home Assistant's own cards send it.- The older names
call-service,serviceandservice_datastill work, and the config checker suggests the current one. When an action sets both an old and a new name, the new one wins, as in Home Assistant.
type: custom:lcards-button
entity: input_boolean.lcards_test_doors
preset: lozenge
text:
name:
show: true
# tap: turn the doors on
tap_action:
action: perform-action
perform_action: input_boolean.turn_on
target:
entity_id: input_boolean.lcards_test_doors
# hold: turn them off
hold_action:
action: perform-action
perform_action: input_boolean.turn_off
target:
entity_id: input_boolean.lcards_test_doors| Key | Type | Default | Description |
|---|---|---|---|
action | string | required | What happens: see Action types |
entity | string | the card's entity | The entity toggle and more-info act on |
perform_action | string | - | perform-action: the action to run, as domain.action (light.turn_on) |
service | string | - | The older name for perform_action |
data | object | - | perform-action: the action's data (brightness_pct: 50) |
service_data | object | - | The older name for data |
target | object | - | perform-action: what the action acts on |
target.entity_id | string / list | - | Entity ids to act on |
target.device_id | string / list | - | Device ids to act on |
target.area_id | string / list | - | Area ids to act on |
browser_mod | object | - | fire-dom-event: what browser_mod runs, in its own grammar (service and data): see browser_mod |
navigation_path | string | - | navigate: the dashboard path, starting with / (/lovelace/bridge). Required |
navigation_replace | boolean | false | navigate: replace the current page in the browser history, so Back skips it |
url_path | string | - | url: the address to open. Required |
pipeline_id | string | preferred | assist: the Assist pipeline to use |
start_listening | boolean | true | assist: start listening as soon as the dialog opens |
confirmation | boolean / object | - | Ask before running: see Confirmation |
| Scene action keys | card, view, point, duration, warp, date, rate and model_scale for the astrometrics actions |
Confirmation
Ask before an action runs, as Home Assistant's own cards do: confirmation: true, or your own question and buttons.
confirmationworks on every action type, including the astrometrics actions. The card's tap sound and animation still play straight away; only the action waits for the answer.- With
confirmation: truethe dialog asks Home Assistant's own translated question naming the action ("Are you sure you want to run action 'Light: Turn on'?"). - Users listed in
exemptionsare not asked: the action runs straight away for them. A user's ID is in Settings > People > Users (with advanced mode on in your profile).
type: custom:lcards-button
entity: input_boolean.lcards_test_doors
preset: lozenge
text:
name:
show: true
tap_action:
action: toggle
confirmation:
title: Airlock
text: Cycle the airlock doors?
confirm_text: Cycle
dismiss_text: Stay
exemptions:
- user: 0123456789abcdef0123456789abcdefMore about confirmation
- Cancel, Esc or a tap outside the dialog runs nothing.
- The phone vibrates with Home Assistant's warning haptic when the dialog opens, in the companion apps.
navigation_replaceis the other Home Assistant action key LCARdS reads: onnavigateit replaces the current page in the browser history, so Back goes past it.
| Key | Type | Default | Description |
|---|---|---|---|
confirmation | boolean / object | - | true asks Home Assistant's default question; an object sets the keys below |
confirmation.text | string | Home Assistant's question | The question |
confirmation.title | string | - | Dialog heading |
confirmation.confirm_text | string | OK (translated) | Confirm button label |
confirmation.dismiss_text | string | Cancel (translated) | Dismiss button label |
confirmation.exemptions | list | - | Users who are not asked, each user: <user id> |
Tap, hold and double-tap
When each of the three actions runs. A hold is a press of half a second; a double tap is two taps close together.
- A hold runs
hold_actionafter 500 ms, and the tap that would follow when you let go is skipped. - When a card has a
double_tap_action, a single tap waits 300 ms for a second tap before it runstap_action. A card without one runs its tap at once. - Each action can name its own
entity, so one card can control several things.
type: custom:lcards-button
entity: input_boolean.lcards_test_lights
preset: lozenge
text:
name:
show: true
# tap: the lights
tap_action:
action: toggle
# double tap: the doors
double_tap_action:
action: toggle
entity: input_boolean.lcards_test_doors| Key | Type | Default | Description |
|---|---|---|---|
tap_action | object | toggle on a button, none on an elbow or slider | What a tap does. The select menu, data grid and astrometrics pages give their own defaults |
hold_action | object | - | What a press held for 500 ms does |
double_tap_action | object | - | What two taps within 300 ms do |
Hover and cursor
The button and elbow cards change colour and can animate when the mouse pointer is over them, and show a hand cursor. Two card-level keys (not keys of an action) turn that off or change the cursor.
interactive
interactive: false makes a button or elbow decorative: no hover colour, no hover animations and the arrow cursor. Use it for a label or panel that should not look clickable.
- A button or elbow with no action, no animation a pointer starts (
on_tap,on_hover, ...) and no entity a tap can toggle is decorative already (a title, a sweep, a filler, a sensor readout); setinteractive: trueto give it hover effects anyway. - Tap, hold and double-tap actions still run on a card with
interactive: false. - The hover sound (
card_hover, see Card Sounds) does not play either.
type: custom:lcards-button
entity: input_boolean.lcards_test_lights
preset: lozenge
# decorative: no hand cursor or hover effects
interactive: false
text:
name:
show: true
# still runs on a tap
tap_action:
action: toggle| Key | Type | Default | Description |
|---|---|---|---|
interactive | boolean | true with an action or a switchable entity, else false | false: no hover colour, hover animations or hover sound, and the arrow cursor. Actions still run |
style.cursor
The mouse cursor over a button or elbow, whatever interactive says. Use it for hover effects with another cursor shape, or for the hand cursor on a decorative card.
type: custom:lcards-button
preset: lozenge
text:
label:
content: TARGET
show: true
style:
cursor: crosshair| Key | Type | Default | Description |
|---|---|---|---|
style.cursor | string | pointer, or default with interactive: false | Any CSS cursor: pointer, default, none, not-allowed, crosshair, grab, zoom-in, help, wait, progress, move, copy, text |