How to add class to navbar-header div

G’day all

I’m trying to customise the presentation of my Yii2 project & for the template I’m trying to apply I need to add a class to the ‘navbar-header’ div.

This snippet is the first tags inside the nav tag for an "out of the box" navbar…


<div class="container"><div class="navbar-header"><button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#w0-collapse"><span class="sr-only">Toggle navigation</span>

It’s the 2nd opening tag there.

Of the options I’ve tried…

‘brandOptions’ applies to the brand button which comes after this snippet,

‘containerOptions’ applies to the ‘container’ div in this snippet, &

‘innerContainerOptions’ applies to the div following the brand button.

Can anyone help?

TIA, Pedro :)

The current code in init() inside NavBar does not provide for customising the navbar-header div so the easiest way to go would be to subclass NavBar with your own version and override (only) the init() method with your own version, copied from yii\bootstrap\NavBar and modified to suit.