marcelorodrigo/filament-barcode-scanner-field
A powerful barcode scanner input field for Filament applications. This package provides an intuitive interface that allows users to scan barcodes using their device's camera directly from your Filament forms. Built with html5-qrcode for reliable cross-browser barcode scanning.

Barcode input field with scan button in dark mode
Install the package via Composer:
composer require marcelorodrigo/filament-barcode-scanner-field
The package will automatically register itself.
You can publish the config file with:
php artisan vendor:publish --tag="filament-barcode-scanner-field-config"
This is the contents of the published config file:
return [
// Configuration options can be added here in future versions
];
Optionally, you can publish the views using:
php artisan vendor:publish --tag="filament-barcode-scanner-field-views"
Use the BarcodeInput component in your Filament forms:
use Marcelorodrigo\FilamentBarcodeScannerField\Forms\Components\BarcodeInput;
public function form(Form $form): Form
{
return $form
->schema([
BarcodeInput::make('barcode')
->label('Product Barcode')
->required(),
]);
}
use Marcelorodrigo\FilamentBarcodeScannerField\Forms\Components\BarcodeInput;
// Simple usage
BarcodeInput::make('sku')
->label('SKU Code')
->placeholder('Scan or enter barcode...')
->required();
use Marcelorodrigo\FilamentBarcodeScannerField\Forms\Components\BarcodeInput;
// Customize with a different Heroicon
BarcodeInput::make('barcode')
->icon('heroicon-o-qr-code')
->label('Scan Product');
| Method | Description | Default |
|---|---|---|
icon(string $icon) |
Set a custom Heroicon for the scan button | heroicon-m-qr-code |
label(string | Htmlable | null $label) |
Set the field label | null |
placeholder(string | Htmlable | null $placeholder) |
Set input placeholder | "Enter {label}..." |
required(bool | string $condition = true) |
Make the field required | false |
Since BarcodeInput extends TextInput, all standard Filament field methods are supported:
BarcodeInput::make('barcode')
->icon('heroicon-o-arrow-right')
->label('Product Barcode')
->placeholder('Scan or type barcode...')
->required()
->unique('products', 'barcode')
->rules(['min:8', 'max:50'])
->helperText('Scan the barcode on the product packaging')
->hint('Required')
->live()
->afterStateUpdated(fn ($state) => $this->lookupProduct($state));
This package includes translations for 31 languages:
📝 Translation Structure
All translations follow this structure:
actions.scan_qrcode - Scan button aria-labelmodal.title - Modal header with :label placeholdermodal.default_label - Default "Barcode" textmodal.close_button - Close button textfield.placeholder_prefix/suffix - Placeholder constructionfield.default_label - Field label fallback🇪🇺 European (21)
en)da)nl)fi)fr)de)el)hu)it)no)pl)pt)pt_BR)ro)ru)sk)es)sv)tr)uk)cs)🇨🇳 Asian (7)
zh_CN)zh_TW)id)ja)ko)th)vi)🌍 Middle Eastern & South Asian (3)
ar)he)hi)To customize translations or add new languages:
php artisan vendor:publish --tag="filament-barcode-scanner-field-translations"
Translation files will be published to resources/lang/vendor/filament-barcode-scanner-field/.
The scanner uses the html5-qrcode library with default settings optimized for common barcodes:
The barcode value is automatically set to the form field when a barcode is successfully scanned. You can add Livewire event listeners to handle the scanned value:
BarcodeInput::make('barcode')
->live()
->afterStateUpdated(function ($state, Set $set) {
// Lookup product by barcode
$product = Product::where('barcode', $state)->first();
if ($product) {
$set('product_name', $product->name);
$set('price', $product->price);
}
});
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Select;
public function form(Form $form): Form
{
return $form
->schema([
BarcodeInput::make('barcode')
->label('Product Barcode')
->required()
->rules(['exists:products,barcode'])
->validationMessages([
'exists' => 'Product with this barcode not found.',
]),
TextInput::make('quantity')
->numeric()
->required()
->default(1),
]);
}
Please see CHANGELOG for more information on recent changes.
Please see CONTRIBUTING for details.
composer test
Please review our security policy on how to report security vulnerabilities.
This package was inspired by jeffersongoncalves/filament-qrcode-field - a QR code field plugin for Filament. Thank you for the great work!
The MIT License (MIT). Please see License File for more information.
How can I help you explore Laravel packages today?