A
A
alysenko2015-09-24 19:52:20
Yii
alysenko, 2015-09-24 19:52:20

How to add font-awesome icons to website menu items in yii2?

There is a menu in yii2, for example, of the following form:

echo Nav::widget([
        'options' => ['class' => 'navbar-nav navbar-right'],
        'items' => [
            ['label' => 'Home', 'url' => ['/site/index']],
            ['label' => 'About', 'url' => ['/site/about']],
            ['label' => 'Contact', 'url' => ['/site/contact']],
            Yii::$app->user->isGuest ?
                ['label' => 'Login', 'url' => ['/site/login']] :
                [
                    'label' => 'Logout (' . Yii::$app->user->identity->username . ')',
                    'url' => ['/site/logout'],
                    'linkOptions' => ['data-method' => 'post']
                ],
        ],
    ]);

How can I add a font-awesome icon before a menu item?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim, 2015-09-24
@alysenko

Use yii2-icons plugin

A
Alexander Bulatov, 2017-05-09
@alexanderbulatov

Here is a solution without plugins, but already a native Yii2 solution:
stackoverflow.com/questions/25832160/yii2-how-can-...

['label' => '', 'url' => ['/site/index'], 'linkOptions' => ['class' => 'fa fa-home']]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question