- Laravel Nova 4
- PHP 8.0 or newer
Install the package via Composer:
composer require nevadskiy/nova-icon-picker
The field simply stores icons as a string representing the icon's name.
To add icons to the field, use the iconset
method, which accepts the name of the iconset and the path to the directory with SVG icons. It is allowed to register multiple iconsets, but it requires defining unique prefixes so that icons can be resolved correctly.
To add a field to a resource, simply add it to resource's fields
method:
use Nevadskiy\Nova\IconPicker\IconPicker;
public function fields(): array
{
return [
IconPicker::make('Icon')
->iconset(
name: 'General'
path: resource_path('svg'),
),
->iconset(
name: 'Brands',
path: resource_path('svg/brands'),
prefix: 'brands/'
)
->indexSize(16)
->detailSize(32),
]
}
It is also possible to configure the field via ServiceProvider
:
public function boot(): void
{
IconPicker::configure(function (IconPicker $icon) {
$icon->iconset(
name: 'Solid',
path: resource_path('svg/solid'),
prefix: 'solid/',
);
$icon->iconset(
name: 'Outline',
path: resource_path('svg/outline'),
prefix: 'outline/',
);
$icon->iconset(
name: 'Brands',
path: resource_path('svg/brands'),
prefix: 'brands/',
);
});
}
The MIT License (MIT). Please see LICENSE for more information.