Changing the html class using snippet

Hello,
I’m working with snippets for a website.
I have a template for my navigation menu, each time I call it with :
<?php snippet('nav') ?>
But i have another page with a different styling, so i’d like the change my nav class in order to style it with css differently (or at least add another id).
I’ve tried : <?php snippet('nav', ['class' => 'somethingelse']) ?>
but I must be doing something wrong, right?

Thanks.

by adding ['class' => 'somethingelse'] you’re simply making available the value inside the snippet that will be accessible using the $class variable.

It’s up to you to then update the snippet accordingly and make sure the class is actually used in your markup.