A Font Awesome icon picker for Laravel Nova.
Demo: https://nova-demo.huth.it/resources/norman-huth-font-awesome-fields
composer require norman-huth/nova-font-awesome-field
/**
* Get the fields displayed by the resource.
*
* @param NovaRequest $request
* @return array
*/
public function fields(NovaRequest $request): array
{
return [
\NormanHuth\FontAwesomeField\FontAwesome::make(__('Icon'), 'icon'),
];
}
In the config file you can specify the available Font Awesome styles and set default parameters for the field.
php artisan vendor:publish --provider="NormanHuth\FontAwesomeField\FieldServiceProvider" --tag="config"
If the field is nullable
, the function to remove the icon is also available.
FontAwesome::make('icon')->nullable()
To bypass the config settings use these methods.
FontAwesome::make('icon')->showStyleSelector()
FontAwesome::make('icon')->hideStyleSelector()
This package uses the global translations, so you don't have to maintain them multiple times.
$this->texts = [
'header' => __('Edit Icon'),
'cancel' => __('Cancel'),
'update' => __('Update'),
'search' => __('Search'),
'remove' => __('Remove Icon'),
'styles' => __('Styles'),
'more' => __('Load more'),
'null' => __('No Icons Found'),
];
use NormanHuth\FontAwesomeField\FontAwesome;
FontAwesome::make('icon')->setText('header', __('Edit Icon'))
FontAwesome::make('icon')->setText('cancel', __('Cancel'))
FontAwesome::make('icon')->setText('update', __('Update'))
FontAwesome::make('icon')->setText('search', __('Search'))
FontAwesome::make('icon')->setText('remove', __('Remove Icon'))
FontAwesome::make('icon')->setText('Styles', __('Styles'))
FontAwesome::make('icon')->setText('more', __('Load more'))
FontAwesome::make('icon')->setText('null', __('No Icons Found'))
Default icons in this package: Font Awesome Free 6.4.0.
- Download the wanted Font Awesome package from the Font Awesome Website
- Copy the
metadata/icons.json
file to Your Laravel installation - Change the
icon-file
path to Youricons.json
in Yourconfig/nova-font-awesome-field.php
config file - Optional, but recommended: Remove unnecessary elements from the
icons.json
withphp artisan nova-fa-field:shrink-icon-file
command