Htmx on links doesn't appear as link #2994
-
When I apply htmx to an "a" element, it doesn't appear as a link (no hand indicator, no full link shown in browser bottom etc), just plain text. It still triggers the link though when clicked.
Actually you can see how it looks here (html enabled): This is what I am expecting: |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Hey, that's normal as htmx doesn't apply any styling (except the default indicator classes), and since browsers don't know about htmx, they use their standard link styling strategy. Without a To make a link look like what you would expect, you can either
Hope this helps |
Beta Was this translation helpful? Give feedback.
-
Thank you but I have a question. If there is both a href and hx-get to same url, doesn't it lead to visiting the server twice? |
Beta Was this translation helpful? Give feedback.
-
Ok, thanks. |
Beta Was this translation helpful? Give feedback.
Hey, that's normal as htmx doesn't apply any styling (except the default indicator classes), and since browsers don't know about htmx, they use their standard link styling strategy. Without a
href
attribute defined, browsers will render your link like a simple text instead of the style you would expect.To make a link look like what you would expect, you can either
href
attribute.In this case, you'll probably want to define
href="/mylink"
. Be aware though that this will let your users right click + open in new tab, which is usually what you want from a link, just don't forget to handle partial swap response vs full page load (you can rely on theHX-Request
header for that, see the