PHP code example of tareq-alqadi / filament-icon-picker

1. Go to this page and download the library: Download tareq-alqadi/filament-icon-picker library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tareq-alqadi / filament-icon-picker example snippets




return [

    'sets' => null,

    'columns' => 1,

    'layout' => \TareqAlqadi\FilamentIconPicker\Layout::FLOATING,
    
    'cache' => [
        'enabled' => true,
        'duration' => '7 days',
    ],

];



use TareqAlqadi\FilamentIconPicker\Forms\IconPicker;

public static function form(Form $form): Form
{
    return $form->schema([
        IconPicker::make('icon');
    ]);
}

use TareqAlqadi\FilamentIconPicker\Forms\IconPicker;

protected function getFormSchema(): array
{
    return [
        IconPicker::make('icon'),
    ];
}

// Make sure this is the correct import, not the filament one
use TareqAlqadi\FilamentIconPicker\Tables\IconColumn;

public static function table(Table $table): Table
{
    return $table
        ->columns([
            IconColumn::make('icon'),
        ])
        // ...
        ;
}

<x-icon name="{{ $category->icon }}" />

// Display 3 columns from lg and above
IconPicker::make('icon')
    ->columns(3); 
    
// More detailed customization
// This will display 1 column from xs to md, 3 columns from lg to xl and 5 columns from 2xl and above
IconPicker::make('icon')
    ->columns([
        'default' => 1,
        'lg' => 3,
        '2xl' => 5,
    ]);

// Search both herocions and fontawesome icons
IconPicker::make('icon')
    ->sets(['heroicons', 'fontawesome-solid']); 

// Allow ONLY heroicon-o-user and heroicon-o-users
IconPicker::make('icon')
    ->allowIcons(['heroicon-o-user', 'heroicon-o-users']);

// Allow ALL fontawesome icons, EXCEPT fas-user
IconPicker::make('icon')
    ->disallowIcons(['fas-user']); 

// 
IconPicker::make('icon')
    ->layout(Layout::FLOATING) // default
    //or
    ->layout(Layout::ON_TOP)

// Render your.blade.template instead of the default template.  
// Make sure to pass the $icon as parameter to be able to render it in your view.
IconPicker::make('icon')
    ->itemTemplate(fn($icon) => view('your.blade.template', ['icon' => $icon]));

IconPicker::make('icon')
    // Disable caching
    ->cacheable(false)
    
    // Cache for one hour
    ->cacheDuration(3600);
bash
php artisan vendor:publish --tag="filament-icon-picker-config"