LaravelPackages.net
Acme Inc.
Toggle sidebar
scadini/nova-icon

A Laravel Nova icon field.

23.572
5
v0.2.1
About scadini/nova-icon

scadini/nova-icon is a Laravel package for a laravel nova icon field.. It currently has 5 GitHub stars and 23.572 downloads on Packagist (latest version v0.2.1). Install it with composer require scadini/nova-icon. Discover more Laravel packages by scadini or browse all Laravel packages to compare alternatives.

Last updated

Nova Icon

Latest Stable Version License

This package allows you to render a SVG icon as a custom field.

Available Icons | Examples | Roadmap


Installation

composer require scadini/nova-icon

Usage

use NovaIcon\Icon;
public function fields()
{
    return [
        ID::make()->sortable(),

        Text::make('Name'),

        Icon::make('Approved')
            ->icon('entypo:check'),
    ];
}
Example 1

The simplest way to add an icon is by using the icon() method. This method accepts either a string or a closure containing the vendor name and the icon name separated by a colon:

    Icon::make('Approved')->icon('entypo:check');
    Icon::make('Approved')->icon(function () {
        return 'entypo:check';
    });

To apply css classes, you can chain the css() method. This method accepts a string, an array, or a closure:

    Icon::make('Approved')->icon('entypo:check')->css('text-info h-12 w-12');

    Icon::make('Approved')->icon('entypo:check')->css(['text-info', 'h-12', 'w-12']);

    Icon::make('Approved')
        ->icon('entypo:check')
        ->css(function () {
            return 'text-info h-12 w-12'; // or ['text-info', 'h-12', 'w-12']
        }
    );

To hide an icon for a specific row, you can use the hide() method. This method accepts a closure:

    Icon::make('Approved')
        ->icon('entypo:check')
        ->hide(function () {
            return $this->role === 'admin';
        });

Example

Here's an example about using this component. Let's say a user has a preferred internet platform:

    Icon::make('Platform')
        ->icon(function () {
            return 'entypo:' . $this->platform;
        })
        ->css(function () {
            $options = [
                'youtube' => 'text-danger',
                'vimeo'   => 'text-success'
            ];

            return $options[$this->platform];
        })
Example 2

Available Icons

The icons available are organized by their vendor name.

Currently, the only vendor available is Entypo, but there are plans to include Zondicons library.

For the icon names you can use this reference table


Roadmap

  • [ ] Add all icons from Entypo
  • [ ] Add all icons from Zondicons
  • [ ] Make icons clickable to perform actions or view resources

Star History Chart