# Nav

> Renders a Bootstrap nav with links, active state detection by route, and items that toggle a yii2\extensions\bootstrap6\Menu.

[API reference](/docs/api/index.md) › [Bootstrap 6](/docs/extensions/bootstrap6/reference/index.md) › Nav

| class | `yii2\extensions\bootstrap6\Nav` |
| --- | --- |
| Extends | [`Widget`](/docs/extensions/bootstrap6/reference/widget/index.md) » [`yii\base\Widget`](/docs/api/yii/base/widget/index.md) » [`yii\base\Component`](/docs/api/yii/base/component/index.md) » [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| Implements | [`yii\base\ViewContextInterface`](/docs/api/yii/base/viewcontextinterface/index.md), [`yii\base\Configurable`](/docs/api/yii/base/configurable/index.md) |
| Uses traits | [`AttributesTrait`](/docs/extensions/bootstrap6/reference/attributestrait/index.md), [`BootstrapWidgetTrait`](/docs/extensions/bootstrap6/reference/bootstrapwidgettrait/index.md) |
| Source | [`src/Nav.php`](https://github.com/yii2-extensions/bootstrap6/blob/main/src/Nav.php#L31) |

Renders a Bootstrap nav with links, active state detection by route, and items that toggle a [`Menu`](/docs/extensions/bootstrap6/reference/menu/index.md).

Menu toggles bind the Menu plugin through the data API; plugin events bubble up to the nav element, so
[`$clientEvents`](/docs/extensions/bootstrap6/reference/bootstrapwidgettrait/index.md#property-clientEvents) such as `shown.bs.menu` can be attached to it.

See also: <https://getbootstrap.com/docs/6.0/components/nav/>.

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-activateItems"></span>`$activateItems` | `bool` | Whether to activate items whose `url` route and parameters match [`$route`](/docs/extensions/bootstrap6/reference/nav/index.md#property-route) and [`$params`](/docs/extensions/bootstrap6/reference/nav/index.md#property-params). Default: `true`. | `Nav` |
| <span id="property-activateParents"></span>`$activateParents` | `bool` | Whether to activate a parent item when one of its menu items is active. Default: `false`. | `Nav` |
| <span id="property-autoIdPrefix"></span>[`$autoIdPrefix`](/docs/api/yii/base/widget/index.md#property-autoIdPrefix) static | `string` | The prefix to the automatically generated widget IDs. Default: `'w'`. | [`yii\base\Widget`](/docs/api/yii/base/widget/index.md) |
| <span id="property-behaviors"></span>[`$behaviors`](/docs/api/yii/base/component/index.md#property-behaviors) read-only | `array<`[`yii\base\Behavior`](/docs/api/yii/base/behavior/index.md)`<static>>` | List of behaviors attached to this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="property-clientEvents"></span>[`$clientEvents`](/docs/extensions/bootstrap6/reference/bootstrapwidgettrait/index.md#property-clientEvents) | `array<string,` [`yii\web\JsExpression`](/docs/api/yii/web/jsexpression/index.md)`\|string>` | Event handlers attached to the widget element, as event name => JavaScript handler source. Default: `[]`. | [`BootstrapWidgetTrait`](/docs/extensions/bootstrap6/reference/bootstrapwidgettrait/index.md) |
| <span id="property-clientOptions"></span>[`$clientOptions`](/docs/extensions/bootstrap6/reference/bootstrapwidgettrait/index.md#property-clientOptions) | `array<string, mixed>\|false` | Options passed to the plugin constructor, or `false` to skip the JavaScript initialization. Default: `[]`. | [`BootstrapWidgetTrait`](/docs/extensions/bootstrap6/reference/bootstrapwidgettrait/index.md) |
| <span id="property-encodeLabels"></span>`$encodeLabels` | `bool` | Whether to HTML-encode the item labels; the item `encode` option takes precedence. Default: `true`. | `Nav` |
| <span id="property-id"></span>[`$id`](/docs/api/yii/base/widget/index.md#property-id) | `string` | Id of the widget. | [`yii\base\Widget`](/docs/api/yii/base/widget/index.md) |
| [`$items`](#property-items) | `array<array-key, array<array-key, mixed>\|`[`yii2\extensions\bootstrap6\item\NavItem`](/docs/extensions/bootstrap6/reference/item/navitem/index.md)`\|string>` | Nav items: [`NavItem`](/docs/extensions/bootstrap6/reference/item/navitem/index.md) instances, arrays converted through [`NavItem::fromArray()`](/docs/extensions/bootstrap6/reference/item/navitem/index.md#method-fromArray), or strings rendered as is. Default: `[]`. | `Nav` |
| <span id="property-layout"></span>`$layout` | [`yii2\extensions\bootstrap6\enum\NavLayout`](/docs/extensions/bootstrap6/reference/enum/navlayout/index.md)`\|string\|null` | Layout class, such as [`NavLayout::FILL`](/docs/extensions/bootstrap6/reference/enum/navlayout/index.md#case-FILL), or `null` for the default layout. Default: `null`. | `Nav` |
| <span id="property-menuClass"></span>`$menuClass` | `class-string<`[`Menu`](/docs/extensions/bootstrap6/reference/menu/index.md)`>` | Class of the menu widget. Default: `\yii2\extensions\bootstrap6\Menu::class`. | `Nav` |
| <span id="property-options"></span>[`$options`](/docs/extensions/bootstrap6/reference/widget/index.md#property-options) | `array<string, mixed>` | HTML attributes of the widget container tag. Default: `[]`. | [`Widget`](/docs/extensions/bootstrap6/reference/widget/index.md) |
| [`$params`](#property-params) | `array<array-key, mixed>\|null` | Query parameters used to detect active items, or `null` to use the current request parameters. Default: `null`. | `Nav` |
| <span id="property-route"></span>`$route` | `string\|null` | Route used to detect active items, or `null` to use the route of the current controller. Default: `null`. | `Nav` |
| <span id="property-style"></span>`$style` | [`yii2\extensions\bootstrap6\enum\NavStyle`](/docs/extensions/bootstrap6/reference/enum/navstyle/index.md)`\|string\|null` | Style class, such as [`NavStyle::TABS`](/docs/extensions/bootstrap6/reference/enum/navstyle/index.md#case-TABS), or `null` for the base nav. Default: `null`. | `Nav` |
| <span id="property-view"></span>[`$view`](/docs/api/yii/base/widget/index.md#property-view) | [`yii\web\View`](/docs/api/yii/web/view/index.md) | The view object that can be used to render views or view files. | [`yii\base\Widget`](/docs/api/yii/base/widget/index.md) |
| <span id="property-viewPath"></span>[`$viewPath`](/docs/api/yii/base/widget/index.md#property-viewPath) read-only | `string` | The directory containing the view files for this widget. | [`yii\base\Widget`](/docs/api/yii/base/widget/index.md) |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| <span id="method-__construct"></span>[`__construct()`](/docs/api/yii/base/baseobject/index.md#method-__construct) | Constructor. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-__call"></span>[`__call()`](/docs/api/yii/base/component/index.md#method-__call) | Calls the named method which is not a class method. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__clone"></span>[`__clone()`](/docs/api/yii/base/component/index.md#method-__clone) | This method is called after the object is created by cloning an existing one. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__get"></span>[`__get()`](/docs/api/yii/base/component/index.md#method-__get) | Returns the value of a component property. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__isset"></span>[`__isset()`](/docs/api/yii/base/component/index.md#method-__isset) | Checks if a property is set, i.e. defined and not null. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__set"></span>[`__set()`](/docs/api/yii/base/component/index.md#method-__set) | Sets the value of a component property. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__unset"></span>[`__unset()`](/docs/api/yii/base/component/index.md#method-__unset) | Sets a component property to be null. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-addAttributes"></span>[`addAttributes()`](/docs/extensions/bootstrap6/reference/attributestrait/index.md#method-addAttributes) | Adds a set of HTML attributes; attributes already set with the same name are replaced. | [`AttributesTrait`](/docs/extensions/bootstrap6/reference/attributestrait/index.md) |
| <span id="method-addClass"></span>[`addClass()`](/docs/extensions/bootstrap6/reference/attributestrait/index.md#method-addClass) | Adds one or more CSS classes to the existing classes; duplicated classes are collapsed. | [`AttributesTrait`](/docs/extensions/bootstrap6/reference/attributestrait/index.md) |
| <span id="method-addCssStyle"></span>[`addCssStyle()`](/docs/extensions/bootstrap6/reference/attributestrait/index.md#method-addCssStyle) | Adds CSS style properties to the `style` attribute. | [`AttributesTrait`](/docs/extensions/bootstrap6/reference/attributestrait/index.md) |
| <span id="method-afterRun"></span>[`afterRun()`](/docs/api/yii/base/widget/index.md#method-afterRun) | This method is invoked right after a widget is executed. | [`yii\base\Widget`](/docs/api/yii/base/widget/index.md) |
| <span id="method-attachBehavior"></span>[`attachBehavior()`](/docs/api/yii/base/component/index.md#method-attachBehavior) | Attaches a behavior to this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-attachBehaviors"></span>[`attachBehaviors()`](/docs/api/yii/base/component/index.md#method-attachBehaviors) | Attaches a list of behaviors to the component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-attribute"></span>[`attribute()`](/docs/extensions/bootstrap6/reference/attributestrait/index.md#method-attribute) | Sets an HTML attribute value. | [`AttributesTrait`](/docs/extensions/bootstrap6/reference/attributestrait/index.md) |
| <span id="method-beforeRun"></span>[`beforeRun()`](/docs/api/yii/base/widget/index.md#method-beforeRun) | This method is invoked right before the widget is executed. | [`yii\base\Widget`](/docs/api/yii/base/widget/index.md) |
| <span id="method-begin"></span>[`begin()`](/docs/api/yii/base/widget/index.md#method-begin) static | Begins a widget. | [`yii\base\Widget`](/docs/api/yii/base/widget/index.md) |
| <span id="method-behaviors"></span>[`behaviors()`](/docs/api/yii/base/component/index.md#method-behaviors) | Returns a list of behaviors that this component should behave as. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-canGetProperty"></span>[`canGetProperty()`](/docs/api/yii/base/component/index.md#method-canGetProperty) | Returns a value indicating whether a property can be read. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-canSetProperty"></span>[`canSetProperty()`](/docs/api/yii/base/component/index.md#method-canSetProperty) | Returns a value indicating whether a property can be set. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-class"></span>[`class()`](/docs/extensions/bootstrap6/reference/attributestrait/index.md#method-class) | Replaces the existing CSS classes with the specified ones. | [`AttributesTrait`](/docs/extensions/bootstrap6/reference/attributestrait/index.md) |
| <span id="method-className"></span>[`className()`](/docs/api/yii/base/baseobject/index.md#method-className) static | Returns the fully qualified name of this class. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-detachBehavior"></span>[`detachBehavior()`](/docs/api/yii/base/component/index.md#method-detachBehavior) | Detaches a behavior from the component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-detachBehaviors"></span>[`detachBehaviors()`](/docs/api/yii/base/component/index.md#method-detachBehaviors) | Detaches all behaviors from the component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-end"></span>[`end()`](/docs/api/yii/base/widget/index.md#method-end) static | Ends a widget. | [`yii\base\Widget`](/docs/api/yii/base/widget/index.md) |
| <span id="method-ensureBehaviors"></span>[`ensureBehaviors()`](/docs/api/yii/base/component/index.md#method-ensureBehaviors) | Makes sure that the behaviors declared in [`behaviors()`](/docs/api/yii/base/component/index.md#method-behaviors) are attached to this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-getBehavior"></span>[`getBehavior()`](/docs/api/yii/base/component/index.md#method-getBehavior) | Returns the named behavior object. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-getBehaviors"></span>[`getBehaviors()`](/docs/api/yii/base/component/index.md#method-getBehaviors) | Returns all behaviors attached to this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-getId"></span>[`getId()`](/docs/api/yii/base/widget/index.md#method-getId) | Returns the ID of the widget. | [`yii\base\Widget`](/docs/api/yii/base/widget/index.md) |
| <span id="method-getView"></span>[`getView()`](/docs/api/yii/base/widget/index.md#method-getView) | Returns the view object that can be used to render views or view files. | [`yii\base\Widget`](/docs/api/yii/base/widget/index.md) |
| <span id="method-getViewPath"></span>[`getViewPath()`](/docs/api/yii/base/widget/index.md#method-getViewPath) | Returns the directory containing the view files for this widget. | [`yii\base\Widget`](/docs/api/yii/base/widget/index.md) |
| <span id="method-hasEventHandlers"></span>[`hasEventHandlers()`](/docs/api/yii/base/component/index.md#method-hasEventHandlers) | Returns a value indicating whether there is any handler attached to the named event. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-hasMethod"></span>[`hasMethod()`](/docs/api/yii/base/component/index.md#method-hasMethod) | Returns a value indicating whether a method is defined. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-hasProperty"></span>[`hasProperty()`](/docs/api/yii/base/component/index.md#method-hasProperty) | Returns a value indicating whether a property is defined for this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| [`init()`](#method-init) | Initializes the widget, validates [`$layout`](/docs/extensions/bootstrap6/reference/nav/index.md#property-layout) and [`$style`](/docs/extensions/bootstrap6/reference/nav/index.md#property-style), and resolves [`$route`](/docs/extensions/bootstrap6/reference/nav/index.md#property-route) and [`$params`](/docs/extensions/bootstrap6/reference/nav/index.md#property-params). | `Nav` |
| <span id="method-off"></span>[`off()`](/docs/api/yii/base/component/index.md#method-off) | Detaches an existing event handler from this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-on"></span>[`on()`](/docs/api/yii/base/component/index.md#method-on) | Attaches an event handler to an event. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-render"></span>[`render()`](/docs/api/yii/base/widget/index.md#method-render) | Renders a view. | [`yii\base\Widget`](/docs/api/yii/base/widget/index.md) |
| <span id="method-renderFile"></span>[`renderFile()`](/docs/api/yii/base/widget/index.md#method-renderFile) | Renders a view file. | [`yii\base\Widget`](/docs/api/yii/base/widget/index.md) |
| [`run()`](#method-run) |  | `Nav` |
| <span id="method-setId"></span>[`setId()`](/docs/api/yii/base/widget/index.md#method-setId) | Sets the ID of the widget. | [`yii\base\Widget`](/docs/api/yii/base/widget/index.md) |
| <span id="method-setView"></span>[`setView()`](/docs/api/yii/base/widget/index.md#method-setView) | Sets the view object to be used by this widget. | [`yii\base\Widget`](/docs/api/yii/base/widget/index.md) |
| [`styleClasses()`](#method-styleClasses) static | Returns the classes of a nav style; [`NavStyle::PILLS_VERTICAL`](/docs/extensions/bootstrap6/reference/enum/navstyle/index.md#case-PILLS_VERTICAL) also needs [`NavStyle::PILLS`](/docs/extensions/bootstrap6/reference/enum/navstyle/index.md#case-PILLS). | `Nav` |
| <span id="method-trigger"></span>[`trigger()`](/docs/api/yii/base/component/index.md#method-trigger) | Triggers an event. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-widget"></span>[`widget()`](/docs/api/yii/base/widget/index.md#method-widget) static | Creates a widget instance and runs it. | [`yii\base\Widget`](/docs/api/yii/base/widget/index.md) |
| [`isChildActive()`](#method-isChildActive) protected | Marks the active menu items and returns them. | `Nav` |
| [`isItemActive()`](#method-isItemActive) protected | Returns whether the item is active. | `Nav` |
| <span id="method-pluginInitialization"></span>[`pluginInitialization()`](/docs/extensions/bootstrap6/reference/bootstrapwidgettrait/index.md#method-pluginInitialization) protected | Returns the JavaScript that initializes a plugin with its normalized constructor options. | [`BootstrapWidgetTrait`](/docs/extensions/bootstrap6/reference/bootstrapwidgettrait/index.md) |
| <span id="method-registerClientEvents"></span>[`registerClientEvents()`](/docs/extensions/bootstrap6/reference/bootstrapwidgettrait/index.md#method-registerClientEvents) protected | Registers the JavaScript event handlers listed in [`$clientEvents`](/docs/extensions/bootstrap6/reference/bootstrapwidgettrait/index.md#property-clientEvents) at [`View::POS_END`](/docs/api/yii/web/view/index.md#const-POS_END). | [`BootstrapWidgetTrait`](/docs/extensions/bootstrap6/reference/bootstrapwidgettrait/index.md) |
| <span id="method-registerPlugin"></span>[`registerPlugin()`](/docs/extensions/bootstrap6/reference/bootstrapwidgettrait/index.md#method-registerPlugin) protected | Registers the plugin asset, the plugin initialization when needed, and the [`$clientEvents`](/docs/extensions/bootstrap6/reference/bootstrapwidgettrait/index.md#property-clientEvents). | [`BootstrapWidgetTrait`](/docs/extensions/bootstrap6/reference/bootstrapwidgettrait/index.md) |
| [`renderItem()`](#method-renderItem) protected | Renders a nav item. | `Nav` |
| [`renderMenu()`](#method-renderMenu) protected | Renders the menu toggled by an item. | `Nav` |

## Events

| Event | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="event-EVENT_INIT"></span>[`EVENT_INIT`](/docs/api/yii/base/widget/index.md#event-EVENT_INIT) | [`yii\base\Event`](/docs/api/yii/base/event/index.md) | An event that is triggered when the widget is initialized via [`init()`](/docs/api/yii/base/widget/index.md#method-init). Event name: `'init'`. Available since 2.0.11. | [`yii\base\Widget`](/docs/api/yii/base/widget/index.md) |
| <span id="event-EVENT_BEFORE_RUN"></span>[`EVENT_BEFORE_RUN`](/docs/api/yii/base/widget/index.md#event-EVENT_BEFORE_RUN) | [`yii\base\WidgetEvent`](/docs/api/yii/base/widgetevent/index.md) | An event raised right before executing a widget. Event name: `'beforeRun'`. Available since 2.0.11. | [`yii\base\Widget`](/docs/api/yii/base/widget/index.md) |
| <span id="event-EVENT_AFTER_RUN"></span>[`EVENT_AFTER_RUN`](/docs/api/yii/base/widget/index.md#event-EVENT_AFTER_RUN) | [`yii\base\WidgetEvent`](/docs/api/yii/base/widgetevent/index.md) | An event raised right after executing a widget. Event name: `'afterRun'`. Available since 2.0.11. | [`yii\base\Widget`](/docs/api/yii/base/widget/index.md) |

## Property details

### $items <span id="property-items"></span>

```php
public array<array-key, array<array-key, mixed>|yii2\extensions\bootstrap6\item\NavItem|string> $items = []
```

Nav items: [`NavItem`](/docs/extensions/bootstrap6/reference/item/navitem/index.md) instances, arrays converted through [`NavItem::fromArray()`](/docs/extensions/bootstrap6/reference/item/navitem/index.md#method-fromArray), or strings rendered
as is.

An array item accepts the following options:

- `label`: `string|Stringable`, required.
- `url`: `array|string|null`, processed by [`Url::to()`](/docs/api/yii/helpers/baseurl/index.md#method-to); `null` renders no `href`.
  Defaults to `#`.
- `active`: `bool`, forces the active state; otherwise it is detected from `url`.
- `disabled`: `bool`, renders the link without `href` and with `aria-disabled="true"`.
- `visible`: `bool`, whether to render the item. Defaults to `true`.
- `encode`: `bool`, whether to HTML-encode the label.
- `linkOptions`: `array`, HTML attributes of the `.nav-link` element.
- `options`: `array`, HTML attributes of the `.nav-item` element.
- `items`: `array|string`, [`Menu::$items`](/docs/extensions/bootstrap6/reference/menu/index.md#property-items) of the menu toggled by the item, or the menu HTML.
- `menuOptions`: `array`, HTML attributes of the `.menu` panel.

### $params <span id="property-params"></span>

```php
public array<array-key, mixed>|null $params = null
```

Query parameters used to detect active items, or `null` to use the current request parameters.

Scalar values are compared with the item `url` parameters as strings, so `42` matches `'42'`; arrays are
compared element by element.

## Method details

### init() <span id="method-init"></span>

```php
public function init(): void
```

Initializes the widget, validates [`$layout`](/docs/extensions/bootstrap6/reference/nav/index.md#property-layout) and [`$style`](/docs/extensions/bootstrap6/reference/nav/index.md#property-style), and resolves [`$route`](/docs/extensions/bootstrap6/reference/nav/index.md#property-route) and
[`$params`](/docs/extensions/bootstrap6/reference/nav/index.md#property-params).

**Throws**

- [`yii\base\InvalidConfigException`](/docs/api/yii/base/invalidconfigexception/index.md): if [`$layout`](/docs/extensions/bootstrap6/reference/nav/index.md#property-layout) or [`$style`](/docs/extensions/bootstrap6/reference/nav/index.md#property-style) is not a value of its enum.

### run() <span id="method-run"></span>

```php
public function run(): string
```

**Returns**

`string`

**Throws**

- [`yii\base\InvalidConfigException`](/docs/api/yii/base/invalidconfigexception/index.md): if an item has no `label`.

### styleClasses() <span id="method-styleClasses"></span>

```php
public static function styleClasses(yii2\extensions\bootstrap6\enum\NavStyle|string|null $style): list<string>
```

Returns the classes of a nav style; [`NavStyle::PILLS_VERTICAL`](/docs/extensions/bootstrap6/reference/enum/navstyle/index.md#case-PILLS_VERTICAL) also needs [`NavStyle::PILLS`](/docs/extensions/bootstrap6/reference/enum/navstyle/index.md#case-PILLS).

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$style` | [`yii2\extensions\bootstrap6\enum\NavStyle`](/docs/extensions/bootstrap6/reference/enum/navstyle/index.md)`\|string\|null` |  |

**Returns**

`list<string>`

**Throws**

- [`yii\base\InvalidConfigException`](/docs/api/yii/base/invalidconfigexception/index.md): if `$style` is a `string` that is not a [`NavStyle`](/docs/extensions/bootstrap6/reference/enum/navstyle/index.md) value.

### isChildActive() <span id="method-isChildActive"></span>

```php
protected function isChildActive(array<array-key, yii2\extensions\bootstrap6\item\MenuItem|string> $items, bool &$active): array<array-key, yii2\extensions\bootstrap6\item\MenuItem|string>
```

Marks the active menu items and returns them.

A menu item with active children is marked active as well. When [`$activateParents`](/docs/extensions/bootstrap6/reference/nav/index.md#property-activateParents) is `true`, `$active` is
set to `true` if any item is active.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$items` | `array<array-key,` [`yii2\extensions\bootstrap6\item\MenuItem`](/docs/extensions/bootstrap6/reference/item/menuitem/index.md)`\|string>` | Menu items, see [`Menu::$items`](/docs/extensions/bootstrap6/reference/menu/index.md#property-items). |
| `$active` | `bool` | Whether the parent item is active. |

**Returns**

`array<array-key,` [`yii2\extensions\bootstrap6\item\MenuItem`](/docs/extensions/bootstrap6/reference/item/menuitem/index.md)`|string>`: Copies of the items, marked through [`MenuItem::withActive()`](/docs/extensions/bootstrap6/reference/item/menuitem/index.md#method-withActive).

### isItemActive() <span id="method-isItemActive"></span>

```php
protected function isItemActive(yii2\extensions\bootstrap6\item\MenuItem|yii2\extensions\bootstrap6\item\NavItem $item): bool
```

Returns whether the item is active.

The item `active` flag takes precedence. Otherwise, an item is active when the first element of its array `url`
is the route [`$route`](/docs/extensions/bootstrap6/reference/nav/index.md#property-route) and the other elements match [`$params`](/docs/extensions/bootstrap6/reference/nav/index.md#property-params). Relative routes are resolved against the
module of the current controller.

Parameters are compared by value: scalars as strings, so `['site/users', 'id' => 42]` matches the query string
`id=42`, and arrays element by element with the same keys. A `null` parameter matches any value.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$item` | [`yii2\extensions\bootstrap6\item\MenuItem`](/docs/extensions/bootstrap6/reference/item/menuitem/index.md)`\|`[`yii2\extensions\bootstrap6\item\NavItem`](/docs/extensions/bootstrap6/reference/item/navitem/index.md) | Nav item, or item of a menu toggled by the nav. |

**Returns**

`bool`

### renderItem() <span id="method-renderItem"></span>

```php
protected function renderItem(yii2\extensions\bootstrap6\item\NavItem|string $item): string
```

Renders a nav item.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$item` | [`yii2\extensions\bootstrap6\item\NavItem`](/docs/extensions/bootstrap6/reference/item/navitem/index.md)`\|string` | Nav item, or a string rendered as is. |

**Returns**

`string`

### renderMenu() <span id="method-renderMenu"></span>

```php
protected function renderMenu(array<array-key, yii2\extensions\bootstrap6\item\MenuItem|string> $items, array<array-key, mixed> $options): string
```

Renders the menu toggled by an item.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$items` | `array<array-key,` [`yii2\extensions\bootstrap6\item\MenuItem`](/docs/extensions/bootstrap6/reference/item/menuitem/index.md)`\|string>` | Menu items, see [`Menu::$items`](/docs/extensions/bootstrap6/reference/menu/index.md#property-items). |
| `$options` | `array<array-key, mixed>` | HTML attributes of the `.menu` panel. |

**Returns**

`string`