Navigate to anchor of lovelace card

I have tried and failed to be able to navigate to a specifik point of a lovelace card. I use button cards to navigate to different tabs in lovelace but I want it to be shortcuts to specific scroll levels. Like with HTML anchors. Is it possible?

3 Likes

Agreed. This seems like a no brainer to me. There just needs to be native support for adding an id attribute to each card.

Someone out there has surely found a workaround or solution for this :thinking:.

I have not found any so far. Apparently not a common enough need.

1 Like

Here’s a possible work-around:

If you use a button-card. Then you can use it to run javascript that allows you to jump to a specific position on the card.

If the javascript in the name field, then it gets called whenever the page is drawn initially which I’m using to scroll to the top when the page is switched to by another script; otherwise, by using a undocumented hack you can trigger javascript code on a tap.

type: custom:button-card
name: |
  [[[
      window.scrollTo(0, 0);
      return "Scroll to Top"
  ]]]
tap_action:
  action: put_anything_here_but_an_official_value
  whatever_literaly: |
    [[[
        window.scrollTo({ top: 0, left: 0, behavior: 'smooth' });
    ]]]
1 Like

The jump to the top is interesting. But I’m actually also interested in the jump to a specific card. For example, I have a start page. On this page, I have buttons to jump to the subpages for all rooms. However, it would be interesting to have important icons for each room on the start page so that you could jump directly to the lamp control, hoover control or alarm clock control on a subpage, for example.

I would just like to jump from the start page to two or three important topics on the subpage without having to scroll first.

Has anyone found out anything new yet?

DE:

Der Sprung nach oben ist schon interessant. Aber eigentlich interessiert mich auch der Sprung zu einer bestimmten Karte. Ich habe zum Beispiel eine Startseite. Auf dieser Seite habe ich Buttons, um zu den Unterseiten für alle Räume zu springen. Es wäre aber interessant, wenn man für jeden Raum auf der Startseite schon wichtige Icons hätte, um auf einer Unterseite zum Beispiel direkt zur Lampensteuerung, zur Staubsaugersteuerung oder zur Weckersteuerung zu springen.

Ich möchte halt gerne von der Startseite zu zwei oder drei wichtigen Themen auf die Unterseite springen, ohne erst scrollen zu müssen.

Hat jemand schon etwas Neues herausbekommen?

If you always want to be, I may have just found something.

It works :slight_smile: