A plugin that helps you to use Iconify in Craft CMS.
- Craft CMS 5.0.0 or later
- PHP 8.2 or later
Open your terminal and run the following commands:
cd /path/to/my-project
composer require craftyfm/iconify
php craft install/plugin iconifyTo be able to use this plugins, you need to set up the storage and the icon sets you want to use. Please follow these following steps:
-
Go to Settings → Plugins → Iconify.
-
Choose your preferred storage option:
-
Local Storage: Icons are saved in
storage/folder.If you're using containers (e.g., Docker), icons may need to be re-downloaded unless storage is persisted.
-
Database: Icons are stored in the database.
Using large icon sets may increase your database size and affect performance.
-
-
Select the icon sets you want to use.
To download icons, you have two options:
- Navigate to Utilities → Iconify in the Craft Control Panel
- Or use the console command:
./craft iconify/download {iconset}Leave {iconset} empty to download all the selected icon sets from the plugin settings.
Use the iconify() Twig function to render icons in your templates:
{{ iconify('home', 'tabler', '#000', '1.5', 24, 24) }}iconName(required): The name of the icon.iconset(required): The icon set (e.g.,tabler,mdi, etc.).color(optional): The fill or stroke color (e.g.,#ff0000orred).stroke(optional): Stroke width (e.g.,1,1.5,2).width(optional) Icon width (e.g., 24,24.1em)height(optional) Icon height (e.g., 24,24.1em)
You can create a iconify field picker in the Control Panel: Currently, we support these configurable features: * Icon color * Stroke width * Icon set(s)
To show the icon in your templates, use the getSvg() method:
{{ entry.fieldHandle.getSvg() }}