Class thoulah\fontawesome\IconComponent

Inheritancethoulah\fontawesome\IconComponent » yii\base\Component

IconComponent provides an easy way to access Font Awesome icons throughout your project.

This allows you to override default settings once instead of per usage or file.

Add IconComponent as component to your Yii config file:

'components' => [
    'fontawesome' => [
        'class' => thoulah\fontawesome\IconComponent::class,
//      'fontAwesomeFolder' => '@npm/fontawesome-pro/svgs',
//      'style' => 'regular',
    ]
]

Now you can globally insert an icon:

echo Yii::$app->fontawesome->name('at');
echo Yii::$app->fontawesome->name('github', 'brands')->fill->('#003865');
echo Yii::$app->fontawesome->name('font-awesome', 'brands')->class('yourClass');

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$defaults \thoulah\fontawesome\config\Defaults Default settings thoulah\fontawesome\IconComponent

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__call() Magic function, sets icon properties. thoulah\fontawesome\IconComponent
__construct() Creates a new IconComponent object. thoulah\fontawesome\IconComponent
__toString() Magic function, returns the SVG string. thoulah\fontawesome\IconComponent
activeFieldAddon() Returns the ActiveField inputTemplate. thoulah\fontawesome\IconComponent
activeFieldIcon() Returns the ActiveField Icon. thoulah\fontawesome\IconComponent
name() Sets the name and style of the icon. thoulah\fontawesome\IconComponent

Property Details

$defaults public property

Default settings

public \thoulah\fontawesome\config\Defaults $defaults null

Method Details

__call() public method

Magic function, sets icon properties.

Supported options are listed in @method, but no support in the docs yet.

public self __call ( $name, $value )
$name string

Property name

$value array

Property value

return self

Updated object

__construct() public method

Creates a new IconComponent object.

public void __construct ( array $overrides = [] )
$overrides array|null

Overrides of the default settings

__toString() public method

Magic function, returns the SVG string.

public string __toString ( )
return string

SVG data

activeFieldAddon() public method

Returns the ActiveField inputTemplate.

public string activeFieldAddon ( \thoulah\fontawesome\string $name, \thoulah\fontawesome\string $style null )
$name string

Name of the icon, or filename

$style string|null

Style of the icon

return string

ActiveField addon with icon and proper code

activeFieldIcon() public method

Returns the ActiveField Icon.

public string activeFieldIcon ( \thoulah\fontawesome\string $name, \thoulah\fontawesome\string $style null )
$name string

Name of the icon, or filename

$style string|null

Style of the icon

return string

ActiveField icon with proper code

name() public method

Sets the name and style of the icon.

public self name ( \thoulah\fontawesome\string $name, \thoulah\fontawesome\string $style null )
$name string

Name of the icon, or filename

$style string|null

Style of the icon

return self

Component object