Clickable link in VerticalLayout

Hi,
How can I add clickable link in VerticalLayout (v11, Java)? Like button, but underlink link.
For example :
VerticalLayout vl = new VerticalLayout();
Link l = new Link(“”, c → Notification.show(“Test”))
vl.add(l);

Thank you,
Matic

Hi,

like this:

   Anchor anchor = new Anchor();
   anchor.setText("say hello");
   anchor.getElement().addEventListener("click", e -> Notification.show("hello") );

TNX. It works.

Nice. Note that generally people expect that clicking links will navigate them somewhere, so take that into account.

-Olli

Adding my 2p., I was looking for exactly this pattern for implementing a breadcrumb widget. In this use case the user will click on an anchor, but instead of the anchor being a static URL it is a combination of a ‘view’ URL and a state inside that view, thus avoiding a full page reload.
Thanks!