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:
- π Mouse wheel zooming
- π±οΈ Click and drag panning
- π±οΈ Double-click zoom to position (configurable level)
- π± Touch support for mobile devices
- β‘ Smooth transitions and animations
- π― Zoom in/out buttons
- π Reset view functionality
- π Real-time zoom percentage display
- π¨ Modern, clean UI design
Filament.PanZoom.Plugin.Video.mov
- PHP 8.3+
- Laravel 10.0+
- Filament 3.3+ or 4.0+
You can install the package via composer:
composer require solution-forest/filament-panzoomAdd 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 & Tables
use 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(),
]);
}
// Infolists
use 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 Schemas
use 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 Schemas
use 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+ Forms
PanZoom::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+ Forms
PanZoom::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:
- Range: 0.5x to 5.0x
- Default: 3.0x (good balance for detail viewing)
- Common values:
2.0- Moderate zoom2.5- Balanced zoom3.0- Default (detailed view)4.0- High zoom5.0- Maximum zoom
You 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)
])| 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.
- Mouse Wheel: Scroll to zoom in/out
- Double-Click: Double-click to zoom to exact position (configurable level, default: 3x). Double-click again to return to fit.
- Zoom Buttons: Click the + and - buttons in the control panel
- Zoom Range: 0.5x to 5x magnification
- Mouse Drag: Click and drag to pan around the image
- Touch Support: Touch and drag on mobile devices
- Reset Button: Click the reset button to return to the original view
- Auto-fit: Images are automatically fitted to the container on load
- Zoom Percentage: Real-time zoom level display
- Cursor States: Visual feedback for grabbable/grabbing states
- Smooth Transitions: Animated zoom and pan movements
The component uses Tailwind CSS classes and is designed to work seamlessly with Filament's design system. The component is fully responsive and includes:
- Modern, clean interface
- Smooth hover effects
- Mobile-friendly touch controls
- Consistent with Filament's design patterns
TypeError: Argument #1 ($component) must be of type Filament\Infolists\Components\Component
- β You're using
PanZoomin an Infolist - β
Use
PanZoomEntryfor Infolists instead
TypeError: Argument #1 ($component) must be of type Filament\Forms\Components\Component
- β You're using
PanZoomEntryin a Form/Action - β
Use
PanZoomfor Forms/Actions instead
Fatal Error: Class was composed with trait conflicts
- β Fixed in v1.2.1+ - update your package
Method not found: label() or columnSpanFull() in Filament 4.0+
- β These methods aren't available in Filament 4.0+ Schemas
- β Remove these method calls or use Filament 3.0+ syntax
Undefined type 'Filament\Schemas\Components\Component'
- β Linter error in Filament 3.0+ environment
- β This is expected - the package uses runtime detection for compatibility
- β
All methods available (
label(),columnSpanFull(), etc.) - β Traditional Forms/Infolists structure
β οΈ Limited methods available (Schemas-based)β οΈ Different structure (configure(Schema $schema))- β Automatic compatibility detection
| 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; |
- Chrome 70+
- Firefox 65+
- Safari 12+
- Edge 79+
composer testPlease 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.