Back Button Lovelace

Is there a way to implement a back button in lovelace so that it goes back to the previous page? I have a few lovelace navigation cards and some buttons link to different cards. Here is a simple flow… Dashboard> Family Room (navigation card)> Family room remote control. I have a button in the family room remote card to go back to the main dashboard but would like a back button card if i want to go back to the family room. I can get to the family room remote control from the main dashboard as well so it would be nice to have a back button for when things are nested. Hope that makes sense.

4 Likes

did you ever figure this out?

this is what worked for me

tap_action:
  action: navigate
  navigation_path: '[[[window.history.back()]]]'
6 Likes

Hmm does that work in the iOS app too or only a browser?

Works in android app and browser, not sure about ios though.

1 Like

does not work for me
in windows / chrome and android

2 Likes

Doesn’t work here either.

Because the code MAY work only inside a custom:button-card.
“MAY” - means “have not tested myself - but that [[[…]]] syntax is used in the custom:button-card”

Yeah got it working :slight_smile:

revive this…

using

type: custom:button-card
template: subview
name: Terug
icon: mdi:arrow-left
tap_action:
  action: navigate
  navigation_path:  >
    [[[ return window.history.back(); ]]]

seems to actually happen but the system responds with an error not navigation path was set…

using a somewhat related button for the menu toggle:

type: custom:button-card
template: subview
icon: mdi:menu
show_name: false
tap_action:
  action: |
    [[[ this.dispatchEvent(new Event('hass-toggle-menu', { bubbles: true,
          composed: true })); ]]]

is even more complex, as it toggle the menu icon on each load, and not on the tap_action…

still looking for ways to prevent that (and not have to use the Mushroom chips that provide this functionality)