Using the Bootstrap widget
Yii2 supports Bootstrap as a core feature. Bootstrap framework CSS and JavaScript files are injected by default in all pages and we could even use this feature to only apply CSS classes or call our own JavaScript function provided by Bootstrap.
However, Yii2 embeds Bootstrap as a widget, and we can access this framework's capabilities like any other widget.
The most used are:
Class name |
Description |
---|---|
|
This class renders an alert Bootstrap component |
|
This class renders a Bootstrap button |
|
This class renders a Bootstrap drop-down menu component |
|
This class renders a |
|
This class renders a |
For example, yii\bootstrap\Nav
and yii\bootstrap\NavBar
are used in the default main template.
This is an extract from the main layout view (in basic/views/layouts/main.php
):
<?php NavBar::begin([ ...