All Projects → blade-ui-kit → Blade Icons

blade-ui-kit / Blade Icons

Licence: mit
A package to easily make use of SVG icons in your Laravel Blade views.

Projects that are alternatives of or similar to Blade Icons

Blade Heroicons
A package to easily make use of Heroicons in your Laravel Blade views.
Stars: ✭ 173 (-85.35%)
Mutual labels:  laravel, svg, icons, blade
Blade Zondicons
A package to easily make use of Zondicons in your Laravel Blade views.
Stars: ✭ 40 (-96.61%)
Mutual labels:  laravel, svg, icons, blade
React Icomoon
It allows you to simply view the icons in the selection.json file provided by Icomoon.
Stars: ✭ 48 (-95.94%)
Mutual labels:  svg, icons
Tailwindcss
A Tailwind CSS frontend preset for the Laravel Framework
Stars: ✭ 1,056 (-10.58%)
Mutual labels:  laravel, blade
Govicons
🇺🇸 US Government themed icons and CSS toolkit
Stars: ✭ 60 (-94.92%)
Mutual labels:  svg, icons
Librecms
Free Open Source Content Management System, based on PHP, Bootstrap and jQuery.
Stars: ✭ 12 (-98.98%)
Mutual labels:  svg, icons
Ikonograph
⚠️ This project is no longer mantained
Stars: ✭ 13 (-98.9%)
Mutual labels:  svg, icons
Boxicons
High Quality web friendly icons
Stars: ✭ 1,104 (-6.52%)
Mutual labels:  svg, icons
Vue Unicons
1000+ Pixel-perfect svg icons for your next project as Vue components
Stars: ✭ 828 (-29.89%)
Mutual labels:  svg, icons
Linearicons
Linearicons is the highest quality set of line icons, matching with minimalist UI designs in iOS.
Stars: ✭ 64 (-94.58%)
Mutual labels:  svg, icons
Laravel Generator
laravel-generator / laravel代码生成器
Stars: ✭ 61 (-94.83%)
Mutual labels:  laravel, blade
Laravel Tinymce Simple Imageupload
Simple image upload for TinyMCE in Laravel.
Stars: ✭ 66 (-94.41%)
Mutual labels:  laravel, blade
Darkbetter
Dark theme for ruTorrent, but better
Stars: ✭ 12 (-98.98%)
Mutual labels:  svg, icons
Beautymail
Send beautiful HTML emails with Laravel
Stars: ✭ 923 (-21.85%)
Mutual labels:  laravel, blade
Mono Icons
Stars: ✭ 899 (-23.88%)
Mutual labels:  svg, icons
Larawind
Larawind - Laravel 8.0+ Jetstream and Tailwind CSS Admin Theme
Stars: ✭ 55 (-95.34%)
Mutual labels:  laravel, blade
React Bootstrap Icons
React component for Bootstrap Icons
Stars: ✭ 71 (-93.99%)
Mutual labels:  svg, icons
Laravel Blade Directives
A collection of nice Laravel Blade directives
Stars: ✭ 813 (-31.16%)
Mutual labels:  laravel, blade
Octicons
A scalable set of icons handcrafted with <3 by GitHub
Stars: ✭ 7,039 (+496.02%)
Mutual labels:  svg, icons
Phosphor Icons
A flexible icon family for the web
Stars: ✭ 56 (-95.26%)
Mutual labels:  svg, icons

Blade Icons

Tests Code Style 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.

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

Join the Discord server: https://discord.gg/Vev5CyE

Icon Packages

This package is a base package to make it easy for you to use SVG icons in your app. If you want to start using a specific icon set, we offer the following ones below:

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

Third Party

In addition to the official packages from above there's also quite some third party ones. Thanks to the community for contributing these!

Requirements

  • PHP 7.3 or higher
  • Laravel 7.14 or higher

Installation

Before installing a new package it's always a good idea to clear your config cache:

php artisan config:clear

Then install the package with composer:

composer require blade-ui-kit/blade-icons

After installing the package, publish the configuration and uncomment the default icon set:

php artisan vendor:publish --tag=blade-icons

Updating

Please refer to the upgrade guide when updating the library.

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:

<?php

return [
    'sets' => [
        'default' => [
            'path' => 'resources/svg',
        ],
    ],
];

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:

<?php

return [
    'sets' => [
        'default' => [
            'path' => 'resources/images/svg',
        ],
    ],
];

Always make sure you're pointing to existing directories.

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:

<?php

return [
    'sets' => [
        'default' => [
            'prefix' => 'icon',
        ],
    ],
];

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

When referencing icons with the Blade directive or 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:

<?php

return [
    'class' => 'icon icon-default',
];

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 overriden.

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:

<x-icon-camera/>

Icons in subdirectories can be referenced using dot notation:

<x-icon-solid.camera/>

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

<x-icon-camera class="icon-lg"/>

Or any other attributes for that matter:

<x-icon-camera class="icon-lg" id="settings-icon" style="color: #555" data-baz/>

Note that with Blade components, using a prefix is always required, even when referencing icons from the default set.

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:

@svg('camera', 'icon-lg')

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

@svg('camera', 'icon-lg', ['id' => 'settings-icon'])

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

@svg('camera', ['id' => 'settings-icon'])

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

@svg('camera', ['class' => 'icon-lg'])

Attributes without a key, are supported too:

@svg('camera', ['data-foo'])

Helper

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

{{ svg('camera')->id('settings-icon')->dataFoo('bar')->dataBaz() }}

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. If want to learn how to create packages first I 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:

use BladeUI\Icons\Factory;

public function register(): void
{
    $this->callAfterResolving(Factory::class, function (Factory $factory) {
        $factory->add('heroicons', [
            'path' => __DIR__ . '/../resources/svg',
            'prefix' => 'heroicon',
        ]);
    });
}

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

<x-heroicon-o-bell/>

@svg('heroicon-o-bell')

{{ svg('heroicon-o-bell') }}

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

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].