parfaitementweb/filament-password-input
Installation:
composer require parfaitementweb/filament-password-input
No additional configuration is required beyond this.
First Use Case:
Replace a standard Filament TextInput for passwords with the enhanced Password component:
use Parfaitementweb\FilamentPasswordInput\Password;
Password::make('password')
->label('New Password')
->required()
->maxLength(32);
This immediately adds a reveal password toggle (eye icon) to the input.
maxLength or enabled features).Password::make('password')
->label('Password')
->rules(['required', 'min:8']);
TextInput::make('password')->password() with this component for built-in toggle functionality.Password::make('api_key')
->copyable(color: 'info')
->inlineSuffix();
inlineSuffix() to keep the UI clean. Use color to match your app’s theme.Password::make('default_password')
->regeneratePassword(color: 'success')
->newPasswordLength(12);
newPasswordLength to enforce consistent password lengths across the app.// app/Providers/AppServiceProvider.php
public function boot(): void
{
Password::configureUsing(function (Password $password) {
$password
->maxLength(24)
->copyable()
->regeneratePassword();
});
}
Password::make('password')
->hidePasswordManagerIcons();
Form Validation:
Ensure the field’s rules() method includes validation logic (e.g., min:8, confirmed). The component handles UX, but Laravel’s validation remains critical.
Password::make('password')
->rules(['required', 'confirmed'])
->column('password');
Livewire/Alpine.js: The component works seamlessly with Filament’s Livewire integration. No additional JavaScript is required for the toggle or copy-to-clipboard features.
Testing: Test password generation and copy functionality in your feature tests:
$this->get('/admin/resource/edit/1')
->assertSee('Copy to clipboard')
->assertSee('Generate new password');
Dark Mode: The component respects Filament’s dark mode settings out of the box. No additional styling is needed.
Password Manager Icons Persistence:
hidePasswordManagerIcons() method uses data-1p-ignore and data-lpignore attributes, but some password managers (e.g., Bitwarden) may ignore these. Test thoroughly in your target environments.input[data-1p-ignore]::after {
display: none !important;
}
Password Generation Length Constraints:
Str::password() requires a minimum length of 3 characters. If you set maxLength(2), the generated password will default to 32 characters (ignoring your maxLength).newPasswordLength(8) to enforce a custom length, even if maxLength is lower.Disabled State:
disabled: true). This is intentional but may surprise users.disabled: false explicitly if these actions should remain available.Language Key Conflicts:
filament-password-input::password.actions.copy.tooltip) may conflict with Filament’s core translations if keys overlap.app::filament-password-input.copy.tooltip).Icon Customization:
FilamentIcon::register() requires the exact alias names (e.g., filament-password-input::copy). Typos will result in missing icons.Console Errors: If the toggle or buttons don’t work, check the browser console for Alpine.js errors. Ensure no other JavaScript is interfering with Filament’s Livewire interactions.
Generated Passwords: Debug custom password generation closures by logging the output:
->regeneratePassword(using: fn () => {
\Log::info('Generating password...');
return 'custom-' . Str::random(10);
})
Form Submission:
Verify that the field’s name attribute matches your model’s fillable fields. Use column('password') to ensure proper database mapping.
Custom Password Strength Meter: Extend the component by adding a password strength indicator using Alpine.js:
Password::make('password')
->extraAttributes(['x-data' => '
function checkStrength() {
const strength = /* your strength logic */;
this.$el.querySelector(".strength-meter").style.width = `${strength}%`;
}
'])
->afterStateUpdated(fn (set) => $emit('check-strength'));
Dynamic Features: Conditionally enable features based on user roles or form context:
Password::make('password')
->when(fn () => auth()->user()->isAdmin(), fn ($component) =>
$component->copyable()->regeneratePassword()
);
Custom Validation: Integrate with Laravel’s validation rules dynamically:
Password::make('password')
->rules(fn (Password $component) => [
'required',
'min:8',
'regex:/[A-Z]/', // Custom rule
]);
Localization: Publish and override language files for multilingual support:
php artisan vendor:publish --tag=filament-password-input-translations
Then edit resources/lang/vendor/filament-password-input/en.php.
Alpine.js Overhead: The component uses Alpine.js for interactivity. If you’re using Filament in a high-frequency form (e.g., bulk actions), monitor performance impact. The overhead is minimal for typical use cases.
Password Generation:
Generating long passwords (e.g., newPasswordLength(64)) may cause slight delays due to Laravel’s Str::password() cryptographic operations. Test with your expected workload.
How can I help you explore Laravel packages today?