The main property of Menu is [[items]], which specifies the possible items in the menu.
A menu item can contain sub-items which specify the sub-menu under that menu item.
Menu checks the current route and request parameters to toggle certain menu items
with active state.
Note that Menu only renders the HTML tags about the menu. It does do any styling.
You are responsible to provide CSS styles to make it look like a real menu.
The following example shows how to use Menu:
php
echo Menu::widget([
'items' => [
Important: you need to specify url as 'controller/action',
not just as 'controller' even if default action is used.
['label' => 'Home', 'url' => ['site/index']],
'Products' menu item will be selected as long as the route is 'product/index'
['label' => 'Products', 'url' => ['product/index'], 'items' => [
['label' => 'New Arrivals', 'url' => ['product/index', 'tag' => 'new']],
['label' => 'Most Popular', 'url' => ['product/index', 'tag' => 'popular']],
]],
['label' => 'Login', 'url' => ['site/login'], 'visible' => Yii::$app->user->isGuest],
],
]);