welkervinicius / nova-fa-icon
An advanced field for Laravel Nova to select Font Awesome icons, with server-side search, pagination, and localization support.
Requires
- php: ^8.1
- illuminate/support: ^10.0|^11.0|^12.0
Requires (Dev)
- laravel/nova: ^5.0
- laravel/nova-devtool: ^1.7
README
An advanced and performant field for Laravel Nova that allows you to search and select Font Awesome icons. Built with a modern architecture, it ensures a fast and fluid user experience, even with thousands of icons.
Features
- Server-Side Search: The search is performed on the backend, including each icon's search terms (e.g., searching for "logout" finds the "right-from-bracket" icon), ensuring maximum performance.
- Infinite Scroll: Icons are loaded on-demand as the user scrolls, making the picker's opening instantaneous.
- Configurable: Allows publishing a configuration file to use your own
icons.json
(ideal for Pro versions) and to define the globally available icon styles. - Flexible: Allows filtering icon styles (
solid
,brands
, etc.) on a per-field basis directly in your Resource. - Localized: The field respects the locale selected in the Nova panel and includes translations for English and Brazilian Portuguese out of the box.
Installation
You can install the package via Composer:
composer require welkervinicius/nova-fa-icon
Initial Setup
For the icons to be displayed, you need to load the Font Awesome stylesheet. The easiest way is via CDN.
In your app/Providers/NovaServiceProvider.php
, inside the boot()
method, add the following line:
public function boot() { parent::boot(); Nova::style('font-awesome', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.1/css/all.min.css'); }
Optional Configuration
You can publish the configuration file to customize the icons.json
path and the default styles.
php artisan vendor:publish --tag="nova-fa-icon-config"
You can also publish the translation files to add new languages or customize the text.
php artisan vendor:publish --tag="nova-fa-icon-lang"
Usage
Basic Usage
In your Nova Resource, simply add the NovaFaIcon
field.
use Welkervinicius\NovaFaIcon\NovaFaIcon; public function fields(Request $request) { return [ // ... NovaFaIcon::make('Icon'), ]; }
Filtering by Styles
You can restrict the available icon styles for a specific field using the styles()
method.
NovaFaIcon::make('Brand Icon', 'brand_icon') ->styles(['brands']), // This will only show icons of the "brands" style. NovaFaIcon::make('Action Icon', 'action_icon') ->styles(['solid', 'regular']), // This will only show solid and regular icons.
Using an Alias
For cleaner code, you can use an alias in your import statement.
use Welkervinicius\NovaFaIcon\NovaFaIcon as FaIcon; // ... FaIcon::make('Icon')->styles(['solid']),
Changelog
Please see CHANGELOG.md for more information on what has changed recently.
Contributing
Please see CONTRIBUTING.md for details.
License
The MIT License (MIT). Please see the License File for more information.