Closed sebastiangug closed 3 years ago
use:active
may be used only with <a>
element since it will compare its href
attribute value with current router's URL.
It is better for a11ty if you will use element <a>
instead <button>
for navigating. You could style <a>
as button.
Thanks for clearing that up! I'll go ahead and try to use tags and style them accordingly.
Although, would you be willing to consider a pull request to enable the use:active to work on a button as well? where it defaults to the href attribute value but if not present looks for "path"?
Or better yet, maybe I can just add a href attribute to a button, that'd be interesting.
Great router by the way, tried about 6-8 different solutions for svelte and they all sucked in one major breaking way or another, but this one worked flawlessly right away with documentation for every use case.
I love the recipes approach as opposed to increasing the bundle with a bunch of stuff we might or might not use.
Or better yet, maybe I can just add a href attribute to a button, that'd be interesting.
You may use data-href
attribute instead of href
. Reading of this attribute is an untended feature, but now we have a use case for it =)
<button
data-href={navitem.path}
on:click={()=>router.goto(navitem.path)}
use:active
>
{button}
</button>
Great router....
Thank you!
I'm not sure if I'm using it wrong, thought I'd post here to see if anyone else is experiencing this issue.
My navigation buttons are actual
<button>
elements iterated over an array, as such: