Create a filter menu of tags of subpages

hej.
i want to filter/toggle my projects by click the tag in a menu. i tried a few things but i dont know how to create the right function:

<ul class="filter-project-menu">
  <?php $menuitems = page('projects')->children(); ?>
    <?php foreach ($menuitems->categories()->split() as $category): ?>
        <li><a href="#" class="<?= $category ?>"><?= $category ?></a></li>
    <?php endforeach ?>
</ul>

$menuitems is a collection, you can use pluck() to get all categories from all items, not split().