After some simple edit on the default navbar, I got the code for the menu below... It would be very ugly if I add more menus.
From the official documentation. I got the answer. I changed the options from nav-pills to navbar-nav
echo Nav::widget([
'items' => [
[
'label' => 'Home',
'url' => ['site/index'],
'linkOptions' => [...],
],
[
'label' => 'Dropdown',
'items' => [
['label' => 'Level 1 - Dropdown A', 'url' => '#'],
'',
'- Dropdown Header
',
['label' => 'Level 1 - Dropdown B', 'url' => '#'],
],
],
],
'options' => ['class' =>'navbar-nav'],
]);