use Filament\Support\RawJs;Â TextInput::make('phone_number') ->mask(RawJs::make(<<<'JS' $input.length >= 14 ? '(99)99999-9999' : '(99)9999-9999' JS))
Go to AppServiceProvider at app\Providers\AppServiceProvider.php and add the following:
use Filament\Facades\Filament;Â /** * Bootstrap any application services. * * @return void */public function boot(){ Filament::registerScripts([ 'https://unpkg.com/@alpinejs/mask@3.x.x/dist/cdn.min.js', ], true);}
TextInput::make('phone_number') ->extraAlpineAttributes(['x-mask:dynamic' => '$input.length >=14 ? \'(99)99999-9999\' : \'(99)9999-9999\''])
Leandro is a PHP/Laravel developer who has been coding for close to 7+ years. You can learn more about Leandro on his website.