© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•13mo ago•
25 replies
charlie

How to use Alpine in Filament?

If I have this very basic example:

MyPage.php

namespace App\Filament\Pages;

class MyPage extends Page implements HasForms
{
    use InteractsWithForms;

    public string $my_text_input = 'Hello, World!';
    public string $another_text_input = 'How are you?';

    public function form(Form $form): Form
    {
        return $form
            ->schema([
                TextInput::make('my_text_input'),
                TextInput::make('another_text_input'),
            ]);
    }
}
namespace App\Filament\Pages;

class MyPage extends Page implements HasForms
{
    use InteractsWithForms;

    public string $my_text_input = 'Hello, World!';
    public string $another_text_input = 'How are you?';

    public function form(Form $form): Form
    {
        return $form
            ->schema([
                TextInput::make('my_text_input'),
                TextInput::make('another_text_input'),
            ]);
    }
}


my-page.blade.php

<x-filament-panels::page>
  
    <script>
        document.addEventListener('alpine:init', () => {
            console.log('Alpine initialized'); // It works

            Alpine.data('my_text_input', ({ state }) => ({
                state,

                init() {
                    console.log(this.state) // Doesn't work
                },
                onclick() {
                    console.log(this.state) // Doesn't work
                },
                change() {
                    console.log(this.state) // Doesn't work
                },

        })
    </script>

    {{ $this->form }}

</x-filament-panels::page>
<x-filament-panels::page>
  
    <script>
        document.addEventListener('alpine:init', () => {
            console.log('Alpine initialized'); // It works

            Alpine.data('my_text_input', ({ state }) => ({
                state,

                init() {
                    console.log(this.state) // Doesn't work
                },
                onclick() {
                    console.log(this.state) // Doesn't work
                },
                change() {
                    console.log(this.state) // Doesn't work
                },

        })
    </script>

    {{ $this->form }}

</x-filament-panels::page>


I can't understand how I can access the field state from alpine...

What if I want to change the state of
another_text_input
another_text_input
each time
my_text_input
my_text_input
state changes, for example?
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

how to use swiperjs in filament
FilamentFFilament / ❓┊help
17mo ago
how to use alpine js floating ui in livewire3?
FilamentFFilament / ❓┊help
3y ago
Add alpine data to filament modal
FilamentFFilament / ❓┊help
3y ago
How to use getFilters in filament charts
FilamentFFilament / ❓┊help
2y ago