Filament v4 Custom Field Plugin: Signature Pad | Mohamed Said       [Skip to content](#main)  [ ![](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png) Mohamed SaidLaravel Backend Engineer ](https://msaied.com) - [Home](https://msaied.com)
- [Projects](https://msaied.com/projects)
- [Articles](https://msaied.com/articles)
- [Certificates](https://msaied.com/certificates)
- [About](https://msaied.com#about)

           [  Contact](https://msaied.com#contact) Menu 

Menu
----

Close 

 - [HomeStart here](https://msaied.com)
- [ProjectsCase studies](https://msaied.com/projects)
- [ArticlesEngineering notes](https://msaied.com/articles)
- [CertificatesCredentials](https://msaied.com/certificates)
- [AboutHow I work](https://msaied.com#about)
- [ContactGet in touch](https://msaied.com#contact)

  [Start a conversation](https://msaied.com#contact) [WhatsApp](https://wa.me/201094619204) [Email](mailto:hello@msaied.com) 

 1. [Home](https://msaied.com)
2. /
3. [Articles](https://msaied.com/articles)
4. /
5. Filament v4 Custom Field Plugins: Building a Reusable Signature Pad Component

 Filament v4 Custom Field Plugins: Building a Reusable Signature Pad Component
==============================================================================

 Learn how to build a production-ready Filament v4 custom field plugin — a signature pad — covering asset registration, schema integration, state hydration, and Livewire interop.

 ![](https://cdn.msaied.com/01M22N44A70A5MC2S599JP0MPH.webp) [Mohamed Said](https://msaied.com#person) Published 5 Jul 2026 · Updated 5 Jul 2026 · 3 min read

ShareCopy linkCopied

 ![Filament v4 Custom Field Plugins: Building a Reusable Signature Pad Component](https://cdn.msaied.com/369/4654a4b25d88862c21064130ec028ffb.png) 

  On this page +1. [Building a Reusable Signature Pad Field for Filament v4](#building-a-reusable-signature-pad-field-for-filament-v4)
2. [Project Structure](#project-structure)
3. [Registering Assets the Right Way](#registering-assets-the-right-way)
4. [The Field Class](#the-field-class)
5. [The Blade View and Alpine Wiring](#the-blade-view-and-alpine-wiring)
6. [The Alpine Component](#the-alpine-component)
7. [Consuming the Field](#consuming-the-field)
8. [Storing the Payload](#storing-the-payload)
9. [Key Takeaways](#key-takeaways)

 Building a Reusable Signature Pad Field for Filament v4
-------------------------------------------------------

Filament v4's unified Schema API makes custom field plugins more composable than ever. Rather than fighting the framework with raw Blade hacks, you can ship a self-contained package that drops cleanly into any `Form`, `Infolist`, or `Table` schema. This walkthrough builds a real signature pad field — the kind you'd use in a contracts or onboarding flow — and covers every layer from asset bundling to state hydration.

### Project Structure

```php
src/
  SignaturePad.php          # Field class
  SignaturePadServiceProvider.php
resources/
  js/signaturePad.js        # Alpine component
  views/
    signature-pad.blade.php

```

### Registering Assets the Right Way

Filament v4 uses `FilamentAsset` for scoped asset loading — assets are only injected when the component is actually rendered, not globally.

```php
// SignaturePadServiceProvider.php
use Filament\Support\Assets\AlpineComponent;
use Filament\Support\Facades\FilamentAsset;

public function boot(): void
{
    FilamentAsset::register([
        AlpineComponent::make('signature-pad', __DIR__ . '/../dist/signature-pad.js'),
    ], package: 'acme/filament-signature-pad');

    $this->loadViewsFrom(__DIR__ . '/../resources/views', 'signature-pad');
}

```

Using `AlpineComponent` instead of a raw `Js` asset tells Filament to lazy-load and register the Alpine component automatically — no manual `Alpine.data()` call in your app.

### The Field Class

```php
// SignaturePad.php
namespace Acme\FilamentSignaturePad;

use Filament\Forms\Components\Field;

class SignaturePad extends Field
{
    protected string $view = 'signature-pad::signature-pad';

    protected bool $clearable = true;
    protected string $format = 'image/png';

    public function clearable(bool $condition = true): static
    {
        $this->clearable = $condition;
        return $this;
    }

    public function format(string $mimeType): static
    {
        $this->format = $mimeType;
        return $this;
    }

    public function getClearable(): bool
    {
        return $this->clearable;
    }

    public function getFormat(): string
    {
        return $this->format;
    }
}

```

Keep the field class thin. Business logic (e.g., converting the base64 payload to a stored file) belongs in a dedicated action or cast, not here.

### The Blade View and Alpine Wiring

```blade
{{-- resources/views/signature-pad.blade.php --}}

            Clear

```

The `ax-load` / `ax-load-src` pattern is Filament v4's lazy Alpine loader. It fetches the component script only when the DOM node is present.

### The Alpine Component

```javascript
// resources/js/signaturePad.js
export default function signaturePad({ state, clearable, format }) {
    return {
        state,
        clearable,
        drawing: false,
        init() {
            const canvas = this.$refs.canvas;
            const ctx = canvas.getContext('2d');
            canvas.addEventListener('mousedown', () => { this.drawing = true; ctx.beginPath(); });
            canvas.addEventListener('mousemove', (e) => {
                if (!this.drawing) return;
                const r = canvas.getBoundingClientRect();
                ctx.lineTo(e.clientX - r.left, e.clientY - r.top);
                ctx.stroke();
            });
            canvas.addEventListener('mouseup', () => {
                this.drawing = false;
                this.state = canvas.toDataURL(format);
            });
        },
        clear() {
            const canvas = this.$refs.canvas;
            canvas.getContext('2d').clearRect(0, 0, canvas.width, canvas.height);
            this.state = null;
        }
    };
}

```

State is synced back to Livewire via `$entangle` on `mouseup` — not on every `mousemove` — keeping wire calls minimal.

### Consuming the Field

```php
use Acme\FilamentSignaturePad\SignaturePad;

SignaturePad::make('signature')
    ->clearable()
    ->format('image/svg+xml')
    ->required()
    ->columnSpanFull(),

```

### Storing the Payload

The field stores a raw base64 data URL. Convert it on save using a model observer or a dedicated action:

```php
// In your CreateRecord action or observer
$data['signature'] = (new StoreSignatureImage)($data['signature']);

```

Keep the conversion outside the field — the field's only job is capturing and surfacing state.

### Key Takeaways

- Use `FilamentAsset::register` with `AlpineComponent` for scoped, lazy asset loading.
- `ax-load` / `ax-load-src` defers Alpine component hydration until the DOM node exists.
- `$entangle` + `$applyStateBindingModifiers` is the canonical way to sync custom field state with Livewire.
- Keep field classes thin; push persistence logic to actions or observers.
- Publish views via `loadViewsFrom` so consumers can override templates without forking the package.

- [filament](https://msaied.com/articles?search=filament)
- [laravel](https://msaied.com/articles?search=laravel)
- [livewire](https://msaied.com/articles?search=livewire)
- [plugins](https://msaied.com/articles?search=plugins)

 Frequently asked questions 
---------------------------

  How do I handle touch events for mobile signature capture?Add `touchstart`, `touchmove`, and `touchend` listeners in your Alpine component alongside the mouse events. Extract the coordinates with `event.touches\[0\].clientX` and call `preventDefault()` on touchmove to stop page scrolling during drawing.

   Can I validate the signature field to ensure it isn't empty?Yes. Because the field stores a string (the data URL) or null, you can chain `-&gt;required()` on the field. For a more precise check — ensuring the canvas isn't just a blank white rectangle — add a custom Filament validation rule that inspects the data URL length or pixel entropy.

   How do I make the component work inside a Filament Infolist for read-only display?Create a companion `SignaturePadEntry` class extending `Filament\\Infolists\\Components\\Entry` with its own Blade view that renders an `&lt;img&gt;` tag from the stored data URL. The field and entry are separate classes in Filament v4's unified Schema API.

   ![Mohamed Said](https://cdn.msaied.com/01M22N44A70A5MC2S599JP0MPH.webp)About the author
----------------

[Mohamed Said](https://msaied.com#person)Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

[About](https://msaied.com#about) [GitHub ↗](https://github.com/EG-Mohamed) [LinkedIn ↗](https://www.linkedin.com/in/msaiedm/) [WhatsApp ↗](https://wa.me/201094619204) [Email Address ↗](mailto:hello@msaied.com) [My CV ↗](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)  

   [Previous articleAdvanced Authorization in Laravel: Gates, Policies, and Response-Based Access Control](https://msaied.com/articles/advanced-authorization-in-laravel-gates-policies-and-response-based-access-control-2) [Next articleOctane Worker Lifecycle, State Leakage, and Safe Singleton Patterns in Laravel](https://msaied.com/articles/octane-worker-lifecycle-state-leakage-and-safe-singleton-patterns-in-laravel)  

   On this page
-------------

1. [Building a Reusable Signature Pad Field for Filament v4](#building-a-reusable-signature-pad-field-for-filament-v4)
2. [Project Structure](#project-structure)
3. [Registering Assets the Right Way](#registering-assets-the-right-way)
4. [The Field Class](#the-field-class)
5. [The Blade View and Alpine Wiring](#the-blade-view-and-alpine-wiring)
6. [The Alpine Component](#the-alpine-component)
7. [Consuming the Field](#consuming-the-field)
8. [Storing the Payload](#storing-the-payload)
9. [Key Takeaways](#key-takeaways)

 ###  Have a technical challenge?

 Tell me what you’re building. I reply within two working days.

[Start a conversation](https://msaied.com#contact) 

   Related articles
-----------------

 [ ![](https://cdn.msaied.com/739/2d6897fdcdcf090613f96f72a64b8a78.png)  · 4 min read### MySQL Full-Text Search in Laravel: Indexes, Relevance Scoring, and Boolean Mode

4 Oct 2026 ](https://msaied.com/articles/mysql-full-text-search-in-laravel-indexes-relevance-scoring-and-boolean-mode) [ ![](https://cdn.msaied.com/738/073696a3fefe18bec825beec5ac658f5.png)  · 4 min read### Laravel Queue Rate-Limited Middleware: Throttling Jobs Without Losing Work

4 Oct 2026 ](https://msaied.com/articles/laravel-queue-rate-limited-middleware-throttling-jobs-without-losing-work) [ ![](https://cdn.msaied.com/737/f5c7e78a645325d4cff8d43f2835f136.png)  · 4 min read### Laravel Telescope Alternatives: Structured Observability with Pulse, Debugbar, and Custom Watchers

4 Oct 2026 ](https://msaied.com/articles/laravel-telescope-alternatives-structured-observability-with-pulse-debugbar-and-custom-watchers) 

  Have a technical challenge?
----------------------------

Tell me what you’re building. I reply within two working days.

 [Discuss your project ↗](https://msaied.com#contact) 

  © 2026 Mohamed Said · Built with Laravel, meant to last.Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

 - [Home](https://msaied.com)
- [Articles](https://msaied.com/articles)
- [Certificates](https://msaied.com/certificates)
- [GitHub](https://github.com/EG-Mohamed)
- [LinkedIn](https://www.linkedin.com/in/msaiedm/)
- [WhatsApp](https://wa.me/201094619204)
- [Email Address](mailto:hello@msaied.com)
- [My CV](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)
- [Sitemap](https://msaied.com/sitemap.xml)
