handcode / yii2-bootstrap-icons
yii2asset bundle for bootstrap icons
Package info
github.com/handcode/yii2-bootstrap-icons
Type:yii2-extension
pkg:composer/handcode/yii2-bootstrap-icons
Requires
- twbs/bootstrap-icons: ^v1.13
- yiisoft/yii2: ~2.0.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-13 19:24:11 UTC
README
This package provide yii2 asset bundles and some very simple helper classes to be able to use
bootstrap icons in yii2 projects.
For more information about bootstrap icons, see: https://icons.getbootstrap.com/
This package use the twbs/bootstrap-icons composer package as source of the icon files.
AssetBundles
BoostrapIconsFont
This Assetbundle publish the bootstrap icon fonts and the matching css/scss files
BoostrapIconsSvg
This AssetBundle publish the bootstrap icon SVG files to a fixed asset dir so one can use the files e.g. in CSS.
The default publishDir is: web/assets/bootstrap/icons/
It can be configured via BoostrapIconsSvg::$fixedPublishDir property.
Helper classes
BaseBI
This (autogenerated) abstract class provide constants for all (currently) available bootstrap icons. This is usefull to get autocompletion in your IDE.
Hint: the constants are all prefixed with an unserscrore as some icon names starts with an integer but PHP only allows constant names that starts with a letter or underscore.
BI
This class extends the BaseBI class.
It provide mainly 2 methods:
BI::icon()
This is the main method to get simple HTML Elements wit hthe required CSS classes to render bootstrap font icons.
The basic usage is:
<?= BI::icon(BI::_CART) ?>
will create
<span class="bi bi-cart"></span>
Example to create an action Button:
<?= BI::icon(BI::_LIST, 'button', null, ['class' => 'btn btn-success', 'title' => 'list content', 'onClick' => 'submit();']) ?>
will create
<button class="btn btn-success bi bi-list" title="list content" onclick="submit();"></button>
as you can see, if $options['class'] exists, the bootstrap icon classes are added to the already defined ones.
BI::getIconClasses()
BI::getIconClasses() can be used to get only the css classes for the given icon name as string or as array.
It is usefull if one would set the classes while generating any HTML Tag or simply inject the classes in HTML or JS "strings".
Example usecases:
- complex View files where the classes should be conditionally injected
- JS config object that has css class properties for action buttons
- ...