Icon Details Map Icon

Latest Stable Version Latest Unstable Version Total Downloads Monthly Downloads Daily Downloads
Thankful to Krajee!
to get more out of us.

NOTE: This extension depends on the yiisoft/yii2-bootstrap and the yiisoft/yii2-jui extensions. Check the composer.json for this extension's requirements and dependencies that may be updated by composer.

This is the first step to setting up the icon framework for your application. The Icon::map method allows you to initialize assets for a specific icon framework in your view. The parameters available for this method are:
  • view: The view object to initialize this framework. Usually you would set it to $this when calling within a view or view layout file.
  • framework: The icon-framework identifier to map to the view. You can use one of the Icon framework constants below:

    • Icon::BSG or "bsg" for Bootstrap Glyphicons
    • Icon::FA or "fa" for Font Awesome Icons
    • Icon::UNI or "uni" for Krajee Uni Icons
    • Icon::EL or "el" for Elusive Icons
    • Icon::TYP or "typ" for Typicons
    • Icon::WHHG or "whhg" for Web Hosting Hub Glyphs
    • Icon::JUI or "jui" for JQuery UI Icons
    • Icon::SI or "si" for Socicon
    • Icon::OCT or "oct" for Github Octicons
    • Icon::FI or "fi" for Flag Icons
    • Icon::OI or "oi" for Open Iconic Icons

In order to setup an icon framework globally, you need to setup icon-framework as a param in your Yii Configuration file. This will have one of the values as determined by the Icon framework constants.

  • Icon::BSG or "bsg" for Bootstrap Glyphicons

  • Icon::FA or "fa" for Font Awesome Icons

  • Icon::EL or "el" for Elusive Icons

  • Icon::TYP or "typ" for Typicons

  • Icon::WHHG or "whhg" for Web Hosting Hub Glyphs

  • Icon::JUI or "jui" for JQuery UI Icons

  • Icon::SI or "si" for Socicon
  • Icon::OCT or "oct" for Github Octicons
  • Icon::UNI or "uni" for Krajee Uni Icons

An example of configuration file settings, and call in the view / layout file is described below.
// Yii Config File 
...
params => [
    'icon-framework' => 'el'  // set elusive icon font as default framework
];
...

// Call this in the view layout (typically at the head section)
use kartik\icons\Icon;
Icon::map($this);

You can also map different icon frameworks to different views. Or, you can use multiple icon frameworks in one single view. You need to pass the icon framework name as the second parameter to Icon::map in your view layout. This will have one of the values as determined by the Icon framework constants.

  • Icon::BSG or "bsg" for Bootstrap Glyphicons

  • Icon::FA or "fa" for Font Awesome Icons

  • Icon::EL or "el" for Elusive Icons

  • Icon::TYP or "typ" for Typicons

  • Icon::WHHG or "whhg" for Web Hosting Hub Glyphs

  • Icon::JUI or "jui" for JQuery UI Icons

  • Icon::SI or "si" for Socicon
  • Icon::OCT or "oct" for Github Octicons
  • Icon::UNI or "uni" for Krajee Uni Icons

An example of mapping icon frameworks specific to each view / layout file is described below. Call these in your view or layout files (typically at the head section)
// Call another framework even if Yii::$app->params['icon-framework'] is set to something else
use kartik\icons\Icon;
Icon::map($this, Icon::WHHG);

// Call multiple icon frameworks in one single view 
// Note: This may affect rendering performance depending on the size of the framework assets.
use kartik\icons\Icon;
Icon::map($this, Icon::EL);
Icon::map($this, Icon::TYP);