How can I add a CSS class on a Label (item)
Example:
['label'=>'Home', 'url'=>['site/home']]
This does not work
['label'=>'Home', 'class'=>'list-group-item', 'url'=>['site/index']],
Just open source of Nav widget:
/**
* @var array list of items in the nav widget. Each array element represents a single
* menu item which can be either a string or an array with the following structure:
*
* - label: string, required, the nav item label.
* - url: optional, the item's URL. Defaults to "#".
* - visible: boolean, optional, whether this menu item is visible. Defaults to true.
* - linkOptions: array, optional, the HTML attributes of the item's link.
* - options: array, optional, the HTML attributes of the item container (LI).
* - active: boolean, optional, whether the item should be on active state or not.
* - items: array|string, optional, the configuration array for creating a [[Dropdown]] widget,
* or a string representing the dropdown menu. Note that Bootstrap does not support sub-dropdown menus.
**/
so if you want to add class to li item, use
['label'=>'Home', 'url'=>['site/index'],'options'=>['class'=>'list-group-item']]
if you want to add class to link
[
'label'=>'Home',
'url'=>['site/index'],
'options'=> ['class'=>'list-group-item'],
'linkOptions'=>['class'=>'item-a-class'],
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With