ianreid / iconlibrairies
SVG icon libraries integration with Craft CMS's native SVG function.
Installs: 20
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:craft-plugin
Requires
- craftcms/cms: ^3.0|^4.0
Requires (Dev)
- craftcms/rector: dev-main
This package is auto-updated.
Last update: 2024-11-12 18:18:27 UTC
README
Icon Libraries for Craft CMS
Easily integrate various SVG icon libraries with Craft CMS's native SVG function.
Requirements
This plugin requires Craft CMS 4.x or later
Installation
To install the plugin, follow these instructions.
-
In your terminal, go to your Craft project:
cd /path/to/project
-
Use Composer to load and install the plugin:
composer require ianreid/iconlibrairies -w && php craft plugin/install icon-librairies
Usage
To utilize the SVGs from the provided libraries, you can simply use the Craft CMS's native SVG function:
{{ svg('@phosphor/shield.svg')|attr({ class: 'w-8 h-8 text-gray-500' }) }}
Example: For using an icon from the phosphor icons library:
{{ svg('@heroicons/o-arrow-right.svg')|attr({ class: 'w-8 h-8 text-green-500' }) }}
Available Icon Libraries
- Phosphor
- Heroicons - When using an icon from Heroicons, prefix the icon name with:
o-
for outline iconss-
for solid iconsm-
for mini icons
SVG Sanitization and Namespacing
By default, if you use the native SVG function, the SVG will be sanitized of potentially malicious scripts using svg-sanitizer, and any IDs or class names within the document will be namespaced so they don’t conflict with other IDs or class names in the DOM. You can disable those behaviors using the sanitize
and namespace
arguments:
{{ svg('@phosphor/shield.svg', sanitize=false, namespace=false) }}
This plugin is brought to you by Ian Reid Langevin