parfaitementweb/filament-password-input
Installation
composer require parfaitementweb/filament-password-input
Publish the config (if needed):
php artisan vendor:publish --provider="Parfaitementweb\FilamentPasswordInput\FilamentPasswordInputServiceProvider" --tag="filament-password-input-config"
First Use Case
Replace a standard Filament TextInput with the enhanced password component in a resource or form:
use Parfaitementweb\FilamentPasswordInput\Forms\Components\PasswordInput;
PasswordInput::make('password')
->required()
->label('Password'),
Filament v5 Support This package now officially supports Filament v5 alongside existing Filament v2/3 compatibility. No additional steps are required—simply install and use as before.
/config/filament-password-input.php for global settings (e.g., default toggle icon, copy button visibility).PasswordInput class methods in your IDE for available customizations.Basic Password Field (Filament v5)
Replace Filament’s default TextInput with PasswordInput in Filament v5 forms:
PasswordInput::make('password')
->required()
->minlength(8)
->maxlength(32),
Customizing Toggle Icon Override the default eye icon (e.g., for a custom SVG) in Filament v5:
PasswordInput::make('password')
->toggleIcon('heroicon-o-eye-slash'),
Conditional Copy Button Show/hide the copy button based on logic (works in Filament v5):
PasswordInput::make('password')
->showCopyButton(fn ($record) => $record->password !== null),
Integration with Filament v5 Forms Use in Filament v5 resource forms, custom panels, or standalone forms:
// In a Filament v5 Resource Form
public static function form(Form $form): Form
{
return $form
->schema([
PasswordInput::make('password')
->required(),
]);
}
Validation Rules
Leverage Filament’s built-in validation (e.g., confirmed for password confirmation) in Filament v5:
PasswordInput::make('password')
->required()
->confirmed(),
Dynamic Defaults Set default values dynamically (e.g., for password reset flows) in Filament v5:
PasswordInput::make('new_password')
->default(fn () => 'AutoGen' . Str::random(4)),
tailwind.config.js or scoped styles (compatible with Filament v5).aria-label and aria-describedby are set for screen readers (tested in Filament v5).$this->filament()->actingAs($user)
->form()
->fillForm([
'password' => 'secure123',
])
->assertSet('password', 'secure123');
Copy Button Security
'show_copy_button' => env('FILAMENT_PASSWORD_INPUT_SHOW_COPY', false),
State Persistence
Conflicts with Filament v5 Plugins
filament-password-input.js.Validation Feedback
dehydrateStateUsing to ensure errors are displayed correctly:
PasswordInput::make('password')
->dehydrateStateUsing(fn ($state) => $state),
PasswordInput::make('password')
->extraAttributes(['data-test-id' => 'password-input'])
->extraJs('console.log("Toggle clicked")'),
Custom Toggle Logic
Override the toggle behavior via extraJs (works in Filament v5):
PasswordInput::make('password')
->extraJs('
document.querySelector("#password-input-toggle").addEventListener("click", function() {
console.log("Custom toggle logic here");
});
'),
Server-Side Processing Extend the component to handle server-side password generation or hashing (compatible with Filament v5):
PasswordInput::make('password')
->afterStateUpdated(fn (set, $state) => Hash::make($state)),
Third-Party Integrations
autocomplete="current-password" (tested in Filament v5).Testing Hooks Add test IDs for automated testing (compatible with Filament v5 testing helpers):
PasswordInput::make('password')
->extraAttributes(['data-test-password-input' => true]),
config/filament-password-input.php (applies to Filament v5):
'toggle_icon' => 'heroicon-o-eye',
'copy_button_delay' => 300,
.env to toggle features (compatible with Filament v5):
FILAMENT_PASSWORD_INPUT_SHOW_COPY=false
How can I help you explore Laravel packages today?