An interactive image zoom and pan component for Filament PHP. This package provides a beautiful, responsive image viewer with smooth zoom and pan functionality, perfect for viewing receipts, documents, or any images that require detailed inspection.
Features:
You can install the package via composer:
composer require solution-forest/filament-panzoom
Add the plugin to your Filament Panel Provider (e.g., app/Providers/Filament/AdminPanelProvider.php
):
use SolutionForest\FilamentPanzoom\FilamentPanzoomPlugin; public function panel(Panel $panel): Panel{ return $panel ->default() ->id('admin') ->path('admin') // ... other configuration ->plugins([ FilamentPanzoomPlugin::make(), // ... other plugins ]);}
Optionally, you can publish the views for customization:
php artisan vendor:publish --tag="filament-panzoom-views"
You can also publish the config file:
php artisan vendor:publish --tag="filament-panzoom-config"
This package supports both Filament 3.0+ and Filament 4.0+ with automatic compatibility detection.
// Forms, Actions & Tablesuse SolutionForest\FilamentPanzoom\Components\PanZoom; public static function form(Form $form): Form{ return $form->schema([ PanZoom::make('image_preview') ->imageUrl(fn ($record) => $record?->image_url) ->label('Image Preview') ->columnSpanFull(), ]);} // Infolistsuse SolutionForest\FilamentPanzoom\Infolists\Components\PanZoomEntry; public function infolist(Infolist $infolist): Infolist{ return $infolist->schema([ PanZoomEntry::make('image_preview') ->imageUrl(fn ($record) => $record?->image_url) ->label('Image Preview'), ]);}
// Forms - Uses Schemasuse SolutionForest\FilamentPanzoom\Components\PanZoom; public static function configure(Schema $schema): Schema{ return $schema->components([ PanZoom::make('image_preview') ->imageUrl(fn ($record) => $record?->image_url), // Note: label() and columnSpanFull() methods not available in 4.0+ ]);} // Infolists - Uses Schemasuse SolutionForest\FilamentPanzoom\Infolists\Components\PanZoomEntry; public static function configure(Schema $schema): Schema{ return $schema->components([ PanZoomEntry::make('image_preview') ->imageUrl(fn ($record) => $record?->image_url), ]);}
You can customize the double-click zoom level for each component. Double-clicking again will return the image to the original fit-to-container view:
// Filament 3.0+ FormsPanZoom::make('image_preview') ->imageUrl(fn ($record) => $record?->image_url) ->doubleClickZoomLevel(2.5) // Zoom to 2.5x instead of default 3x ->label('Image Preview'); // Filament 4.0+ FormsPanZoom::make('image_preview') ->imageUrl(fn ($record) => $record?->image_url) ->doubleClickZoomLevel(4.0) // Zoom to 4x for more detail ->columnSpanFull(); // Infolists (both 3.0+ and 4.0+)PanZoomEntry::make('image_preview') ->imageUrl(fn ($record) => $record?->image_url) ->doubleClickZoomLevel(2.0) // Zoom to 2x ->imageId(fn ($record) => 'image-' . $record->id);
Available Zoom Levels:
2.0
- Moderate zoom2.5
- Balanced zoom3.0
- Default (detailed view)4.0
- High zoom5.0
- Maximum zoomYou can use the component directly in any Blade view (works in both 3.0+ and 4.0+):
@include('filament-panzoom::filament-panzoom', [ 'imageUrl' => 'https://example.com/image.jpg', 'imageId' => 'unique-image-id', 'doubleClickZoomLevel' => 2.5 // Custom zoom level (double-click again to return to fit)])
⚠️ Important: Choose the correct component for your context!
Context | Component | Import |
---|---|---|
Forms (3.0+) | PanZoom |
use SolutionForest\FilamentPanzoom\Components\PanZoom; |
Forms (4.0+) | PanZoom |
use SolutionForest\FilamentPanzoom\Components\PanZoom; |
Actions | PanZoom |
use SolutionForest\FilamentPanzoom\Components\PanZoom; |
Tables | PanZoom |
use SolutionForest\FilamentPanzoom\Components\PanZoom; |
Infolists (3.0+) | PanZoomEntry |
use SolutionForest\FilamentPanzoom\Infolists\Components\PanZoomEntry; |
Infolists (4.0+) | PanZoomEntry |
use SolutionForest\FilamentPanzoom\Infolists\Components\PanZoomEntry; |
Why two components? Filament has separate component hierarchies for Forms and Infolists. Using the wrong one will cause a TypeError.
Feature | Filament 3.0+ | Filament 4.0+ |
---|---|---|
Forms Structure | form(Form $form): Form |
configure(Schema $schema): Schema |
Infolists Structure | infolist(Infolist $infolist): Infolist |
configure(Schema $schema): Schema |
Available Methods | label() , columnSpanFull() , etc. |
Limited methods (Schemas-based) |
Component Base | Filament\Forms\Components\Component |
Filament\Schemas\Components\Component |
Auto-detection | ✅ Yes | ✅ Yes |
In Forms:
public static function form(Form $form): Form{ return $form->schema([ PanZoom::make('image_preview') ->imageUrl(fn ($record) => $record?->image_url) ->label('Image Preview') ->columnSpanFull(), ]);}
In Infolists:
use SolutionForest\FilamentPanzoom\Infolists\Components\PanZoomEntry; public function infolist(Infolist $infolist): Infolist{ return $infolist->schema([ PanZoomEntry::make('receipt_image') ->imageUrl(fn ($record) => asset('storage/' . $record->image_path)) ->label('Receipt Image') ->imageId(fn ($record) => 'receipt-' . $record->id), ]);}
In Table Actions:
public static function table(Table $table): Table{ return $table->actions([ Action::make('viewImage') ->form([ PanZoom::make('image_viewer') ->imageUrl(fn ($record) => $record->image_url) ->label('Image Viewer'), ]) ]);}
In Custom Pages:
protected function getFormSchema(): array{ return [ PanZoom::make('document_viewer') ->imageUrl($this->imageUrl) ->label('Document Viewer') ->columnSpanFull(), ];}
In Forms (Schemas):
public static function configure(Schema $schema): Schema{ return $schema->components([ PanZoom::make('image_preview') ->imageUrl(fn ($record) => $record?->image_url), // Note: label() and columnSpanFull() methods not available in 4.0+ ]);}
In Infolists (Schemas):
use SolutionForest\FilamentPanzoom\Infolists\Components\PanZoomEntry; public static function configure(Schema $schema): Schema{ return $schema->components([ PanZoomEntry::make('receipt_image') ->imageUrl(fn ($record) => asset('storage/' . $record->image_path)) ->imageId(fn ($record) => 'receipt-' . $record->id), ]);}
In Table Actions:
public static function table(Table $table): Table{ return $table->actions([ Action::make('viewImage') ->form([ PanZoom::make('image_viewer') ->imageUrl(fn ($record) => $record->image_url), ]) ]);}
In Custom Pages:
protected function getFormSchema(): array{ return [ PanZoom::make('document_viewer') ->imageUrl($this->imageUrl), // Note: columnSpanFull() method not available in 4.0+ ];}
The component accepts the following properties:
Property | Type | Required | Description |
---|---|---|---|
imageUrl |
string | Yes | The URL of the image to display |
imageId |
string | Yes | Unique identifier for the component instance |
doubleClickZoomLevel |
float | No | Zoom level for double-click (0.5-5.0, default: 3.0) |
💡 Pro Tip: Double-click anywhere on the image to zoom to that exact position (configurable, default 3x). Double-click again to return to fit.
The component uses Tailwind CSS classes and is designed to work seamlessly with Filament's design system. The component is fully responsive and includes:
TypeError: Argument #1 ($component) must be of type Filament\Infolists\Components\Component
PanZoom
in an InfolistPanZoomEntry
for Infolists insteadTypeError: Argument #1 ($component) must be of type Filament\Forms\Components\Component
PanZoomEntry
in a Form/ActionPanZoom
for Forms/Actions insteadFatal Error: Class was composed with trait conflicts
Method not found: label() or columnSpanFull() in Filament 4.0+
Undefined type 'Filament\Schemas\Components\Component'
label()
, columnSpanFull()
, etc.)configure(Schema $schema)
)Context | Component | Import |
---|---|---|
Forms (3.0+) | PanZoom |
use SolutionForest\FilamentPanzoom\Components\PanZoom; |
Forms (4.0+) | PanZoom |
use SolutionForest\FilamentPanzoom\Components\PanZoom; |
Actions | PanZoom |
use SolutionForest\FilamentPanzoom\Components\PanZoom; |
Tables | PanZoom |
use SolutionForest\FilamentPanzoom\Components\PanZoom; |
Infolists (3.0+) | PanZoomEntry |
use SolutionForest\FilamentPanzoom\Infolists\Components\PanZoomEntry; |
Infolists (4.0+) | PanZoomEntry |
use SolutionForest\FilamentPanzoom\Infolists\Components\PanZoomEntry; |
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.