nedarta/yii2-extended-navbar
最新稳定版本:1.0.1
Composer 安装命令:
composer require nedarta/yii2-extended-navbar
包简介
An extended NavBar widget for Yii2 with support for external items and Bootstrap 5.
README 文档
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)
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-02-06