### Install Filament Icon Picker Package Source: https://context7.com/lukas-frey/filament-icon-picker/llms.txt Install the package via Composer and publish assets for use in your Filament panel. ```bash composer require guava/filament-icon-picker ``` ```bash php artisan filament:assets ``` -------------------------------- ### Install Filament Icon Picker via Composer Source: https://github.com/lukas-frey/filament-icon-picker/blob/main/README.md Use this command to add the package to your project. Ensure you have Composer installed. ```bash composer require guava/filament-icon-picker ``` -------------------------------- ### Complete Filament Resource Example Source: https://context7.com/lukas-frey/filament-icon-picker/llms.txt Integrates the IconPicker into a Filament resource for form fields and table columns. Requires importing necessary components. ```php schema([ TextInput::make('name') ->required() ->maxLength(255), TextInput::make('slug') ->required() ->maxLength(255), IconPicker::make('icon') ->label('Category Icon') ->sets(['heroicons']) ->gridSearchResults() ->closeOnSelect() ->required() ->columnSpanFull(), ]); } public static function table(Table $table): Table { return $table ->columns([ IconColumn::make('icon') ->size(IconSize::Medium) ->color('primary'), TextColumn::make('name') ->searchable() ->sortable(), TextColumn::make('slug') ->searchable(), ]) ->defaultSort('name'); } } ``` -------------------------------- ### Basic IconPicker Form Field Setup Source: https://context7.com/lukas-frey/filament-icon-picker/llms.txt Configure the IconPicker form field in your Filament resource. This basic setup includes a default icon picker. ```php schema([ // Basic icon picker IconPicker::make('icon'), // Icon picker with custom placeholder IconPicker::make('nav_icon') ->placeholder('Select a navigation icon...'), // Required icon field IconPicker::make('category_icon') ->required() ->label('Category Icon'), ]); } } ``` -------------------------------- ### Publish Filament Assets Source: https://github.com/lukas-frey/filament-icon-picker/blob/main/README.md Run this Artisan command after installation to publish the package's assets. This is a required step for the plugin to function correctly. ```bash php artisan filament:assets ``` -------------------------------- ### Run Package Tests Source: https://github.com/lukas-frey/filament-icon-picker/blob/main/README.md Execute the package's test suite using Composer. This command is useful for verifying the installation and ensuring the plugin is working as expected. ```bash composer test ``` -------------------------------- ### Configure Icon Picker Search Results to List View Source: https://github.com/lukas-frey/filament-icon-picker/blob/main/README.md This option displays search results in a list, showing both the icon and its corresponding name. Useful for a more compact view. ```php IconPicker::make('icon') ->listSearchResults(); ``` -------------------------------- ### Add Icon Picker to Filament Form Schema Source: https://github.com/lukas-frey/filament-icon-picker/blob/main/README.md Integrate the IconPicker component into your Filament form schemas. Import the `IconPicker` class from `Guava\ ```php use Guava\IconPicker\Forms\Components\IconPicker; IconPicker::make('icon'); ``` -------------------------------- ### Display Search Results in Grid Layout Source: https://context7.com/lukas-frey/filament-icon-picker/llms.txt Configure the IconPicker to display search results in a grid layout using `gridSearchResults()`. This is the default behavior. ```php gridSearchResults(); ``` -------------------------------- ### Render Icons on Frontend with Blade Source: https://context7.com/lukas-frey/filament-icon-picker/llms.txt Use the x-icon component or svg() helper to render icons stored by the picker. Recommended for most use cases. ```blade {{-- Using the x-icon component (recommended) --}} ``` ```blade {{-- With dynamic sizing --}} ``` ```blade {{-- Using the svg() helper function --}} {!! svg($category->icon, 'w-6 h-6') !!} ``` ```blade {{-- Conditional rendering with fallback --}} @if($category->icon) @else @endif ``` ```blade {{-- In a navigation list --}} @foreach($menuItems as $item) {{ $item->label }} @endforeach ``` -------------------------------- ### Enable Custom SVG Icon Uploads Source: https://context7.com/lukas-frey/filament-icon-picker/llms.txt Enables users to upload custom SVG icons directly through the icon picker interface. Uploaded icons are stored on the public disk and can be scoped to specific models. ```php customIconsUploadEnabled(); ``` ```php // Enable with model scoping for per-record custom icons IconPicker::make('icon') ->customIconsUploadEnabled() ->scopedTo(fn ($record) => $record); ``` ```php // Conditionally enable uploads based on user permissions IconPicker::make('icon') ->customIconsUploadEnabled(fn () => auth()->user()->can('upload-icons')); ``` -------------------------------- ### Configure Icon Picker Search Results to Grid View Source: https://github.com/lukas-frey/filament-icon-picker/blob/main/README.md This option sets the icon picker to display search results in a grid format, with each icon and its name visible. This is the default view. ```php IconPicker::make('icon') ->gridSearchResults(); ``` -------------------------------- ### Control Dropdown Behavior with IconPicker::dropdown() Source: https://context7.com/lukas-frey/filament-icon-picker/llms.txt Manage whether the icon picker opens as a dropdown overlay or displays inline below the field using the `dropdown()` method. A conditional callback can also be provided. ```php dropdown(); // Inline search and results (no dropdown) IconPicker::make('icon') ->dropdown(false); // Conditionally use dropdown based on context IconPicker::make('icon') ->dropdown(fn () => ! request()->isMobile()); ``` -------------------------------- ### Limit Icon Sets with IconPicker::sets() Source: https://context7.com/lukas-frey/filament-icon-picker/llms.txt Use the `sets()` method to restrict the available icon sets in the IconPicker. You can specify single or multiple sets, or provide a dynamic callback. ```php sets(['heroicons']); // Show multiple specific sets IconPicker::make('icon') ->sets(['heroicons', 'fontawesome', 'tabler']); // Dynamically set allowed icon sets IconPicker::make('icon') ->sets(fn () => config('app.allowed_icon_sets')); ``` -------------------------------- ### Add Icon Picker CSS to Theme Source: https://github.com/lukas-frey/filament-icon-picker/blob/main/README.md Include this CSS import in your custom Filament theme's `theme.css` file to ensure the icon picker's styles are correctly processed. This is necessary for older Filament versions or specific theme configurations. ```css @source '../../../../vendor/guava/filament-icon-picker/resources/**/*'; ``` -------------------------------- ### Configure Icon Picker Search Results to Icons View Source: https://github.com/lukas-frey/filament-icon-picker/blob/main/README.md This option displays only the icons in a small grid. You can optionally enable tooltips to show the icon name on hover. ```php IconPicker::make('icon') ->iconsSearchResults() // With tooltip ->iconsSearchResults(false); // Without tooltip ``` -------------------------------- ### Customize Icon Picker Search Results View Source: https://context7.com/lukas-frey/filament-icon-picker/llms.txt Allows setting a custom Blade view for rendering search results. Use this for advanced customization beyond the built-in views. ```php searchResultsView('components.custom-icon-results'); ``` ```php // Custom view with additional view data IconPicker::make('icon') ->searchResultsView('components.custom-icon-results', [ 'showCategories' => true, 'iconsPerRow' => 6, ]); ``` -------------------------------- ### Display Icon in Filament Table Column Source: https://github.com/lukas-frey/filament-icon-picker/blob/main/README.md Use the `IconColumn` class to display the selected icon in your Filament tables. Ensure you import the correct `IconColumn` from `Guava\IconPicker\Tables\Columns\IconColumn`, not the default Filament one. ```php // Make sure this is the correct import, not the filament one use Guava\IconPicker\Tables\Columns\IconColumn; $table ->columns([ IconColumn::make('icon'), ]) // ... ; ``` -------------------------------- ### Display Search Results in List Layout Source: https://context7.com/lukas-frey/filament-icon-picker/llms.txt Use `listSearchResults()` to display icon search results in a vertical list format, showing icons inline with their full names. ```php listSearchResults(); ``` -------------------------------- ### Limit Icon Sets in Picker Source: https://github.com/lukas-frey/filament-icon-picker/blob/main/README.md Restrict the available icon sets in the picker by providing an array of set names to the `sets()` method. This is useful if you only want to offer specific icon collections. ```php IconPicker::make('icon') ->sets(['heroicons']); ``` -------------------------------- ### IconPicker::customIconsUploadEnabled() Source: https://context7.com/lukas-frey/filament-icon-picker/llms.txt Enables the ability for users to upload custom SVG icons directly through the icon picker interface. Uploaded icons are stored on the public disk and can be scoped to specific models. ```APIDOC ## IconPicker::customIconsUploadEnabled() ### Description Enables the ability for users to upload custom SVG icons directly through the icon picker interface. Uploaded icons are stored on the public disk and can be scoped to specific models. ### Method `customIconsUploadEnabled(callable|bool $condition = true)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```php // Enable custom icon uploads IconPicker::make('icon') ->customIconsUploadEnabled(); // Enable with model scoping for per-record custom icons IconPicker::make('icon') ->customIconsUploadEnabled() ->scopedTo(fn ($record) => $record); // Conditionally enable uploads based on user permissions IconPicker::make('icon') ->customIconsUploadEnabled(fn () => auth()->user()->can('upload-icons')); ``` ### Response None (This is a configuration method) #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Display Icons Only in Search Results Source: https://context7.com/lukas-frey/filament-icon-picker/llms.txt Configure the IconPicker to show only icons in search results using `iconsSearchResults()`. Tooltips with names are enabled by default but can be disabled. ```php iconsSearchResults(); // Icons-only view without tooltips IconPicker::make('icon') ->iconsSearchResults(withTooltips: false); ``` -------------------------------- ### Scope Custom Icons to Eloquent Model Source: https://context7.com/lukas-frey/filament-icon-picker/llms.txt Enables custom icon uploads and scopes them to a specific Eloquent model. Icons are stored in model-specific directories and only visible when editing that model. ```php customIconsUploadEnabled() ->scopedTo(fn ($record) => $record); ``` ```php // Scope icons to a related model IconPicker::make('icon') ->customIconsUploadEnabled() ->scopedTo(fn ($record) => $record->organization); ``` -------------------------------- ### Set Icon Display Size in Table Column Source: https://context7.com/lukas-frey/filament-icon-picker/llms.txt Sets the display size of icons in the table column. Accepts Filament's IconSize enum values or custom string sizes. ```php size(IconSize::Small); ``` ```php // Medium icons IconColumn::make('icon') ->size(IconSize::Medium); ``` ```php // Large icons (default) IconColumn::make('icon') ->size(IconSize::Large); ``` ```php // Extra large icons IconColumn::make('icon') ->size(IconSize::ExtraLarge); ``` ```php // Dynamic size based on record IconColumn::make('icon') ->size(fn ($record) => $record->is_featured ? IconSize::Large : IconSize::Small); ``` -------------------------------- ### Display Icons in Filament Tables Source: https://context7.com/lukas-frey/filament-icon-picker/llms.txt The IconColumn displays stored icon values in Filament tables, rendering the actual icon with customizable size, color, and tooltip options. ```php columns([ // Basic icon column IconColumn::make('icon'), // Icon column with custom size IconColumn::make('icon') ->size(IconSize::Large), // Icon column with color IconColumn::make('icon') ->color('primary'), // Icon column with dynamic color based on state IconColumn::make('status_icon') ->color(fn (string $state): string => match ($state) { 'heroicon-o-check-circle' => 'success', 'heroicon-o-x-circle' => 'danger', default => 'gray', }), // Icon column with tooltip IconColumn::make('icon') ->tooltip(fn ($record) => $record->icon_label), // Icon column with placeholder for empty values IconColumn::make('icon') ->placeholder('No icon'), ]); } } ``` -------------------------------- ### IconColumn::size() Source: https://context7.com/lukas-frey/filament-icon-picker/llms.txt Sets the display size of icons in the table column. Accepts Filament's IconSize enum values or custom string sizes. ```APIDOC ## IconColumn::size() ### Description Sets the display size of icons in the table column. Accepts Filament's IconSize enum values or custom string sizes. ### Method `size(IconSize|string $size)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```php // Small icons IconColumn::make('icon') ->size(IconSize::Small); // Medium icons IconColumn::make('icon') ->size(IconSize::Medium); // Large icons (default) IconColumn::make('icon') ->size(IconSize::Large); // Extra large icons IconColumn::make('icon') ->size(IconSize::ExtraLarge); // Dynamic size based on record IconColumn::make('icon') ->size(fn ($record) => $record->is_featured ? IconSize::Large : IconSize::Small); ``` ### Response None (This is a configuration method) #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### IconPicker::scopedTo() Source: https://context7.com/lukas-frey/filament-icon-picker/llms.txt Scopes custom icon uploads to a specific Eloquent model. When enabled with custom uploads, icons are stored in model-specific directories and only visible when editing that model. ```APIDOC ## IconPicker::scopedTo() ### Description Scopes custom icon uploads to a specific Eloquent model. When enabled with custom uploads, icons are stored in model-specific directories and only visible when editing that model. ### Method `scopedTo(callable $callback)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```php // Scope icons to the current record IconPicker::make('icon') ->customIconsUploadEnabled() ->scopedTo(fn ($record) => $record); // Scope icons to a related model IconPicker::make('icon') ->customIconsUploadEnabled() ->scopedTo(fn ($record) => $record->organization); ``` ### Response None (This is a configuration method) #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### IconPicker::searchResultsView() Source: https://context7.com/lukas-frey/filament-icon-picker/llms.txt Allows setting a completely custom Blade view for rendering search results. Use this for advanced customization beyond the built-in grid, list, and icons views. ```APIDOC ## IconPicker::searchResultsView() ### Description Allows setting a completely custom Blade view for rendering search results. Use this for advanced customization beyond the built-in grid, list, and icons views. ### Method `searchResultsView(string $view, array $data = [])` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```php // Use a custom view for search results IconPicker::make('icon') ->searchResultsView('components.custom-icon-results'); // Custom view with additional view data IconPicker::make('icon') ->searchResultsView('components.custom-icon-results', [ 'showCategories' => true, 'iconsPerRow' => 6, ]); ``` ### Response None (This is a configuration method) #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Control Icon Picker Dropdown Close Behavior Source: https://context7.com/lukas-frey/filament-icon-picker/llms.txt Controls whether the dropdown automatically closes when an icon is selected. By default, the dropdown remains open. ```php closeOnSelect(); ``` ```php // Keep dropdown open after selection (default) IconPicker::make('icon') ->closeOnSelect(false); ``` -------------------------------- ### Render Icon on Frontend Source: https://github.com/lukas-frey/filament-icon-picker/blob/main/README.md To display the stored icon on your frontend, use the `` component provided by blade-icons. Pass the stored icon name as the `name` attribute. ```blade ``` -------------------------------- ### Disable Icon Picker Dropdown Source: https://github.com/lukas-frey/filament-icon-picker/blob/main/README.md By default, the icon picker uses a dropdown. Setting `dropdown(false)` will render the search and results directly below the field, similar to a standard Filament select input. ```php IconPicker::make('icon') ->dropdown(false); ``` -------------------------------- ### IconColumn Table Column Source: https://context7.com/lukas-frey/filament-icon-picker/llms.txt The IconColumn displays stored icon values in Filament tables. It renders the actual icon with customizable size, color, and tooltip options. ```APIDOC ## IconColumn Table Column ### Description The IconColumn displays stored icon values in Filament tables. It renders the actual icon with customizable size, color, and tooltip options. ### Method `IconColumn::make(string $name)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```php // Basic icon column IconColumn::make('icon'), // Icon column with custom size IconColumn::make('icon') ->size(IconSize::Large), // Icon column with color IconColumn::make('icon') ->color('primary'), // Icon column with dynamic color based on state IconColumn::make('status_icon') ->color(fn (string $state): string => match ($state) { 'heroicon-o-check-circle' => 'success', 'heroicon-o-x-circle' => 'danger', default => 'gray', }), // Icon column with tooltip IconColumn::make('icon') ->tooltip(fn ($record) => $record->icon_label), // Icon column with placeholder for empty values IconColumn::make('icon') ->placeholder('No icon'), ``` ### Response #### Success Response (200) Displays the icon in a table column. #### Response Example N/A (This is a table column definition) ``` -------------------------------- ### IconPicker::closeOnSelect() Source: https://context7.com/lukas-frey/filament-icon-picker/llms.txt Controls whether the dropdown automatically closes when an icon is selected. By default, the dropdown remains open allowing users to compare and change their selection. ```APIDOC ## IconPicker::closeOnSelect() ### Description Controls whether the dropdown automatically closes when an icon is selected. By default, the dropdown remains open allowing users to compare and change their selection. ### Method `closeOnSelect(bool $condition = true)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```php // Close dropdown immediately after selection IconPicker::make('icon') ->closeOnSelect(); // Keep dropdown open after selection (default) IconPicker::make('icon') ->closeOnSelect(false); ``` ### Response None (This is a configuration method) #### Success Response (200) N/A #### Response Example N/A ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.