Download the PHP package blade-ui-kit/blade-icons without Composer

On this page you can find all versions of the php package blade-ui-kit/blade-icons. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package blade-icons

Blade Icons

Tests

Coding Standards

Latest Stable Version

Total Downloads

A package to easily make use of SVG icons in your Laravel Blade views. Originally "Blade SVG" by Adam Wathan.

Turn...

Into...

Or into...

Looking for a specific icon? Try our icon search: https://blade-ui-kit.com/blade-icons#search

Any sponsorship to help fund development is greatly appreciated ❤️

Icon Packages

Blade Icons is a base package to make it easy for you to use SVG icons in your app. In addition, there's also quite some third party icon set packages. Thanks to the community for contributing these!

We're not accepting requests to build new icon packages ourselves but you can start building your own.

Requirements

Installation

Install the package with composer:

Then, publish the configuration and uncomment the default icon set:

Make sure that the path defined for this icon set exists. By default it's resources/svg. Your SVG icons will need to be placed in this directory.

Upgrading

Please refer to the upgrade guide when upgrading the library.

Caching

When working with Blade Icons, and third party icon sets in particular, you'll often be working with large icon sets. This can slow down your app tremendously, especially when making use of Blade components. To solve this issue, Blade Icons ships with caching support. To enable icon caching you can run the following command:

This will create a blade-icons.php file in bootstrap/cache similar to the packages.php cached file. It'll contain a manifest of all known sets and icons with their path locations.

Caching icons means you won't be able to add extra icons, change paths for icon sets or install/remove icon packages. To do so make sure you first clear the icons cache and cache after you've made these changes:

It's a good idea to add the icons:cache command as part of your deployment pipeline and always cache icons in production.

Alternatively, you may choose to disable Blade components entirely.

Also, when adding new icons, renaming directories in your icon paths, it's always a good idea to clear your views before refreshing the page:

Configuration

Defining Sets

Blade Icons support multiple sets. You can define these by passing a key/value combination in the blade-icons.php config file's sets setting:

Feel free to add as many sets as you wish. Blade Icons ships with a default set for your app which you may adjust to your liking.

Icon Paths

If you wanted to add icons from a different directory in your app, say resources/images/svg, you can set it like this:

[!WARNING]
Always make sure you're pointing to existing directories.

Multiple Paths

In addition to a single path, you may define multiple paths for a single set with the paths option instead:

This gives you the benefit from grouping icons from different paths under a single set where you can define the same prefix and default classes.

[!WARNING] When using multiple paths instead of one, Blade Icons will return the first icon it finds when an icon name is present in more than one path. Please ensure you use unique icon names when registering multiple paths if you want to retrieve the correct icon.

Filesystem Disk

If you host your icons on an external filesystem storage you can set the disk option for an icon set to a disk defined in your filesystems.php config file. For example, you might store your icons on an AWS S3 bucket which is set in your filesystems.php config file with a disk key of s3-icons:

And from now on our default set will pull the icons from the S3 bucket. Also notice we've adjusted the path to / because we store our icons in the root directory of this S3 bucket. If you have several icon sets uploaded to the same disk you can set your paths accordingly:

Fallback Icons

If you want to provide a fallback icon when an icon cannot be found, you may define the fallback option on a specific set:

Now when you try to resolve a non-existing icon for the default icon set, it'll return the rendered "cake" icon instead.

You can also provide a global fallback icon instead. This icon will be used when an icon cannot be found and the set doesn't have its own fallback icon defined. It can reference any icon from any registered icon set.

[!NOTE] There's one caveat when using fallback icons and that is that they don't work when using Blade Components. In this case, Laravel will throw an exception that the component cannot be found. If you want to make use of fallback icons please consider one of the other usages.

Prefixing Icons

In the default icon set the icon prefix will be applied to every icon, but you're free to adjust this in the blade-icons.php config file:

Defining a prefix for every set is required and every prefix should be unique.

When referencing icons with the helper you can omit the prefix to reference icons from the default set. When referencing icons from other sets, using the prefix is required.

When an icon in the default set has a name which collides with a prefix from a set then the icon from the default set is retrieved first.

Please note that it's best practice that your icons themselves do not have the prefix in their name. So if you have a prefix in your set called icon and your icons are named icon-example.svg you should rename them to example.svg. Otherwise you can run into unexpected name resolving issues.

It's also important to note that icon prefixes cannot contain dashes (-) as this is the delimiter which we use to split it from the rest of the icon name.

Default Classes

You can optionally define classes which will be applied to every icon by filling in the class setting in your blade-icons.php config file:

If you don't want any classes to be applied by default then leave this as an empty string. Additionally, the same option is available in sets so you can set default classes on every set.

The sequence in which classes get applied is <global classes> <set classes> <explicit classes>. You can always override this by passing an explicit class with your attributes. Component classes cannot be overridden.

Default Attributes

You can also optionally define some attributes which will be added to every icon in the attributes setting of your blade-icons.php config file:

This always needs to be an associative array. Additionally, the same option is available in sets so you can set default attributes on every set.

The sequence in which classes get applied is default attributes / set attributes / explicit attributes where the latter overwrites the former. It is not possible to overwrite existing attributes on SVG icons. If you already have attributes defined on icons which you want to override, remove them first.

Usage

There are several ways of inserting icons into your Blade templates. We personally recommend using Blade components, but you can also make use of a Blade directive if you wish.

Components

The easiest way to get started with using icons from sets are Blade components:

Icons in subdirectories can be referenced using dot notation:

You can also pass classes to your icon components (default classes will be applied as well):

Or any other attributes for that matter:

[!NOTE] With Blade components, using a prefix is always required, even when referencing icons from the default set.

Deferring icons

When you're using the same icon in lots of places on the page the DOM element count may explode upwards. To remedy this you can add the defer attribute to the components:

This will push the icons to the stack "bladeicons", you should load this stack at the bottom of your page

[!WARNING] Deferring icons is only possible using the <x-icon> component. This feature doesn't work with the @svg Blade directive or the svg() helper function.

Using deferred icons in JavaScript

You can re-use your icons from blade in your JavaScript rendered views by providing a custom defer value that will be used as an identifier:

Then, in your JavaScript, create an svg element with use and href="#icon-{your-hash}" attribute.

Default Component

If you don't want to use the component syntax from above you can also make use of the default Icon component that ships with Blade Icons. Simply pass the icon name through the $name attribute:

If you want to use a different name for this component instead you can customize the components.default option in your blade-icons.php config file:

Then reference the default icon as follow:

You can also completely disable this default component if you want by setting its name to null:

Disabling Components

Although they're enabled by default, if you don't wish to use components at all you may choose to disable them completely by setting the components.disabled setting in your blade-icons.php config file to true:

Doing this makes sense when you're only using the helper and can improve overall performance.

Directive

If components aren't really your thing you can make use of the Blade directive instead. If you defined a default icon class in your config and want to render a camera icon with an icon-lg class you can do that like so:

Any additionally attributes can be passed as a third array argument, and they'll be rendered on the svg element:

If you don't have a class to be defined you can also pass these attributes as the second parameter:

If you want to override the default classes, pass in the class as an attribute:

Attributes without a key, are supported too:

Helper

If you'd like, you can use the svg helper to expose a fluent syntax for setting SVG attributes:

Accessibility

If the icon should have semantic meaning, a text alternative can be added with the title attribute. Refer to the Usage section of this documentation to learn how to add an attribute.

For almost all use cases, your icon will be assuming the role of an image. This means that deciding on if your icon has any semantic meaning, or what that semantic meaning is, you can use the WCAG alt text decision tree.

If your icon has semantic meaning, using the title attribute will apply the following features to the SVG element:

Example usage:

Example result:

If your icon does not have semantic meaning, you may want to hide the icon to reduce overall document clutter. You may do this by adding aria-hidden="true" to your icon.

Building Packages

If you're interested in building your own third party package to integrate an icon set, it's pretty easy to do so. We've created a template repo for you to get started with. You can find the getting started instructions in its readme.

If you want to learn how to create packages we can recommend these two excellent courses:

Make sure to load your SVGs from the register method of your package's service provider. Provide the path to your SVGs and provide your own unique set name and component prefix:

Now your icons can be referenced using a component, directive or helper:

Don't forget to make blade-ui-kit/blade-icons a requirement of your package's composer.json.

Generating Icons

Blade Icons also offers an easy way to generate icons for your packages. By defining a config file with predefined source and destination paths, you can make updating your icons a breeze.

First, start off by creating a generation.php config file in the config directory of your icon package. Next, you can define an array per icon set that you want to generate. Below is a full version of this file with explanation for every option. Only the source and destination options are required.

See an example config/generation.php file for the Heroicons package.

After setting up your config file you can use the icon generation as follow from the root of your icon package directory:

Changelog

Check out the CHANGELOG in this repository for all the recent changes.

Maintainers

Blade Icons is developed and maintained by Dries Vints.

License

Blade Icons is open-sourced software licensed under the MIT license.


All versions of blade-icons with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4|^8.0
illuminate/contracts Version ^8.0|^9.0|^10.0|^11.0
illuminate/filesystem Version ^8.0|^9.0|^10.0|^11.0
illuminate/support Version ^8.0|^9.0|^10.0|^11.0
illuminate/view Version ^8.0|^9.0|^10.0|^11.0
symfony/console Version ^5.3|^6.0|^7.0
symfony/finder Version ^5.3|^6.0|^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package blade-ui-kit/blade-icons contains the following files

Loading the files please wait ....