Main UI Widget - Any way to get the page name?

I am finally getting in to making pages and widgets in the Main UI on Openhab5. It’s very powerful, but a lot to learn. I have several questions and I’m trying to find the answers to them on the forum, but one that is eluding me is this: Is there a way to get the page name you’re on from within a widget?

Here is the use case, I’ve got a home page with page-link buttons (oh-label cards) labeled “Kitchen”, Livingroom”, “Outdoor” (for example). There are pages with the exact same names that each button navigate to, and the same buttons are on all pages so that navigation can happen to anywhere via these buttons. On the home page all of the link buttons are a light-grey, but on the individual room pages I would like the page-link-button of the page that you’re currently on to turn a darker grey and navigate back to the home overview page. To do this within the widget code automatically i need to be able to get the current page (Page_ID) the widget is on. Is this possible?

Not directly, no. But there is a way to pass information to a page when navigating to it. The navigate action can take an additional parameter besides actionPage called actionPageDefineVars. This property is an object and each key will be a page variable you can access in the new page that opens. So you could do something like this:

action: navigate
actionPage: page:Kitchen
actionPageDefineVars:
  currentPage: KITCHEN

and on the Kitchen page then you can use vars.currentPage like this

color: =(vars.currentPage=='KITCHEN')?('darkgray'):('lightgray')

Fantastic! @JustinG thank you very much! This should work great.