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

yii\bootstrap\Alert

This class renders an alert Bootstrap component

yii\bootstrap\Button

This class renders a Bootstrap button

yii\bootstrap\Dropdown

This class renders a Bootstrap drop-down menu component

yii\bootstrap\Nav

This class renders a nav HTML component

yii\bootstrap\NavBar

This class renders a ...

Get Yii2 By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.