Skip to content

Sage Docs

How to use blade-icons

The blade-icons package allows you to easily use SVG's in your Blade views.

Besides being able to use your own SVG's, you can also add one of the many third party icon sets, such as:

Screenshot of blade-icons home page

Installation

From the same directory where you've installed Acorn (typically your site root or your Sage theme folder), add blade-icons as a Composer dependency:

Then publish the configuration file:

Configuration

From the published config/blade-icons.php file, we recommend setting the default set to point to your theme directory:

Adding icons

Add a new directory inside resources/images/ named icons/ and place your SVG icons in this directory.

Using icons in Blade views

From your Blade views you can now use the provided Blade component, or the @svg directive:

Adding icon sets

blade-icons supports a lot of different icon sets through packages made through the community. The Blade icons search allows you to quickly find a new icon to use in your project.

To add aditional icon sets, require them as Composer dependencies the same as you did for the blade-icons package. In this example, we'll add the blade-heroicons package:

Now Heroicons can be referenced in any of the supported methods from inside your Blade views:

<x-heroicon-s-menu /> @svg('heroicon-s-menu') {{ svg('heroicon-s-menu) }}

Additional information

The blade-icons README covers how to pass attributes, set default classes, and more.

Contributors

Last updated

Support Roots

Help us continue to build and maintain our open source projects. We’re a small team of independent developers and every little bit helps.

Sponsor Roots on GitHub