I’ve got problem migrating an app to the BS4 with yiisoft/yii2-bootstrap4 extension.
Using the Navbar / Nav widget as follows:
use yii\bootstrap4\Nav; use yii\bootstrap4\NavBar; NavBar::begin([ 'brandLabel' => 'Biblioteczka', 'brandUrl' => Yii::$app->homeUrl, 'options' => [ 'class' => 'navbar navbar-expand-md navbar-dark bg-dark', [...] echo Nav::widget([ 'options' => ['class' => 'navbar-nav ml-auto'], 'items' => $menuItems, ]); NavBar::end();
I end up with wrong formatted Navbar (notice that Nav items are not aligned vertically with the brand element, they are moved up):
I think the issue is related to the Nav widget code which adds the ‘nav’ class to the ‘ul’ html markup:
So, the produced code has extra ‘nav’ class, besides the ones I specified in ‘options’:
<ul id="w3" class="navbar-nav ml-auto nav"> <li class="nav-item"> [...]
But looking to the BS4 docs: https://getbootstrap.com/docs/4.0/components/navbar/ the ‘ul’ markup has to have only the ‘navbar-nav’ class.
Of course I can simply fix it overriding the Nav::Init method but maybe I overlooked something? Has the extra ‘nav’ class to be there for some reasons?