Add class to Ul of the nav

Hi i am converting a menu from HTML to yii2 , and using nav and navbar to build the menu i am on the last section and want to apply a class on the main UL of the menu and remove the default class nav from it, but cant seem to find out how to do so ,does any one know how can i remove default class to the UL i.e. nav class. i know that using the option property of the NAV class i can add the custom class but it still appends to the nav class with it , how can i disable that class.

below is my code


NavBar::begin([

        'innerContainerOptions'=>['class'=>'container-fluid style-ihozflemitemsContainer'],

        'options' => [

            'class' => 'style-ihozflem','style'=>'left: 125px; width: 730px; position: absolute; top: 20px; height: 24px;','data'=>['state'=>'center notMobile', 'dropmode'=>"dropDown"]

        ],

        

    ]);echo Nav::widget([

        'encodeLabels'=>false,

        options=>['class'=>'my-class'],

        'activateItems'=>true,

        'items' => $menuItems,

        

    ]);

    NavBar::end();

Nav menu is the boostrap menu and the nav class is part of boostrap.

Usually the correct way is to change it is to override the nav class at css level.

But I know that sometime bootstrap is a bit too "resistant" to class override

just declare your options/class as follow and the trick is done




   	'options'=>['class'=>['widget'=>'my-class']],



1 Like

By the way you made an error in your code, you missed ’ around options

[color="#00FF00"][/color]options[color="#00FF00"][/color]=>[‘class’=>‘my-class’],