nedarta / yii2-extended-navbar
An extended NavBar widget for Yii2 with support for external items and Bootstrap 5.
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- yiisoft/yii2: ^2.0.0
- yiisoft/yii2-bootstrap5: ^2.0.0
README
A Bootstrap 5-compatible NavBar widget for Yii2 that adds support for external navigation items and enhanced customization options.
Key Features
- Bootstrap 5 compatibility with modern navbar styling
- External navigation items that remain visible outside the collapsible section
- Flexible positioning options for external items (left, right, or before toggle)
- Support for dynamic dropdowns in both regular and external items
- Comprehensive customization options for all navbar elements
Installation
composer require nedarta/yii2-extended-navbar
Basic Usage
use nedarta\navbar\ExtendedNavBar; use yii\helpers\Html; echo ExtendedNavBar::widget([ 'brandLabel' => 'My Company', 'brandUrl' => Yii::$app->homeUrl, 'options' => [ 'class' => 'navbar-expand-lg navbar-light bg-light', ], 'externalItems' => Nav::widget([ 'options' => ['class' => 'navbar-nav ms-auto d-flex flex-row gap-2 me-3'], //configure as needed 'items' => [ ['label' => 'EN', 'url' => ['/site/language', 'lang' => 'en']], ['label' => 'LV', 'url' => ['/site/language', 'lang' => 'lv']], ], ]), ]); ?> <?= Nav::widget([ 'options' => ['class' => 'navbar-nav ms-auto'], 'items' => [ ['label' => 'Home', 'url' => ['/site/index']], ['label' => 'About', 'url' => ['/site/about']], ['label' => 'Contact', 'url' => ['/site/contact']], ], ]);
Configuration Options
External Items Structure
Each external item can be:
// Simple link ['label' => 'Home', 'url' => ['/site/index']] // Dropdown menu [ 'label' => 'Account', 'items' => [ ['label' => 'Profile', 'url' => ['/user/profile']], ['label' => 'Settings', 'url' => ['/user/settings']], '<hr class="dropdown-divider">', ['label' => 'Logout', 'url' => ['/site/logout']], ], ] // Custom HTML Html::tag('li', Html::a('<i class="fas fa-user"></i>', ['/profile'], ['class' => 'nav-link']), ['class' => 'nav-item'] )
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
- Create an issue in the GitHub repository
- Contact the maintainer at GitHub
Developed with ❤️ by Edgars Karlsons (nedarta)