Reset applied filter / tags with link

Dear lovely Kirby-Forum!

I am currently developing a site where I can filter the content with different tags / categories. Everything is working fine. The only thing left to add now is a “Reset Filter” option.
Of course I could just add “Reset Filter” as standard option and link back to the main site, but that’s not beautiful.
A button that reads “x NameOfTag” (the “x” stands for the close-icon) instead of “Reset Filter” feels more elegant and I want it to be shown only when a tag is applied.
As I am more of a frontend guy with zero PHP knowledge I don’t succeed in building the if condition.

Thanks in advance for helping out.
Have a nice day.
Best, Christian.

How have you done the filtering exactly? Can you not use Ajax / jquery to do live filtering? Something like this or this

All you need is an if condition:

<?php if($param = param('category')): ?>
  <a class="button" href="<?= $page->url() ?>"><span>&times;</span> <?= $param ?></a>
<?php endif ?>

Edit: If you are not using jQuery anyway, and want a JS filtering solution, I’d go for a vanilla script, something like list.js, jet.js

Oh wow, thank you for the quick reply.
Worked perfectly.

Btw: Kirby really helps to learn a bit of php on the fly. Something that I really appreciate compared to a twig-based cms.

Thank you very much for the help.
Best, Christian