Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Filament Password Input Laravel Package

parfaitementweb/filament-password-input

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps

  1. Installation:

    composer require parfaitementweb/filament-password-input
    

    No additional configuration is required beyond this.

  2. 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.

Where to Look First

  • README.md: Focus on the Usage section for quick implementation examples.
  • Global Configuration: Check the Global Configuration section if you need to standardize settings across all password fields (e.g., default maxLength or enabled features).
  • Language Overrides: Review the Copy to Clipboard and Password Generation sections for customization options like tooltips or confirmation messages.

Implementation Patterns

Core Workflows

1. Basic Password Field with Toggle

Password::make('password')
    ->label('Password')
    ->rules(['required', 'min:8']);
  • Use Case: Standard password input in user profile or registration forms.
  • Pattern: Replace TextInput::make('password')->password() with this component for built-in toggle functionality.

2. Password with Copy-to-Clipboard

Password::make('api_key')
    ->copyable(color: 'info')
    ->inlineSuffix();
  • Use Case: Admin panels where users need to copy sensitive keys (e.g., API tokens, database credentials).
  • Pattern: Combine with inlineSuffix() to keep the UI clean. Use color to match your app’s theme.

3. Password Generation for Defaults

Password::make('default_password')
    ->regeneratePassword(color: 'success')
    ->newPasswordLength(12);
  • Use Case: Forms where users can generate a secure default (e.g., database migrations, service accounts).
  • Pattern: Use newPasswordLength to enforce consistent password lengths across the app.

4. Global Configuration for Consistency

// app/Providers/AppServiceProvider.php
public function boot(): void
{
    Password::configureUsing(function (Password $password) {
        $password
            ->maxLength(24)
            ->copyable()
            ->regeneratePassword();
    });
}
  • Use Case: Enforce company-wide security policies (e.g., max password length, mandatory copy-to-clipboard).
  • Pattern: Override defaults in a service provider to avoid repetitive code in forms.

5. Password Manager Integration Control

Password::make('password')
    ->hidePasswordManagerIcons();
  • Use Case: Local development environments or forms where password managers (e.g., 1Password) should not inject UI.
  • Pattern: Use sparingly—only when necessary to avoid disrupting user workflows.

Integration Tips

  • 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.


Gotchas and Tips

Pitfalls

  1. Password Manager Icons Persistence:

    • The 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.
    • Workaround: Use CSS to hide the icons if needed:
      input[data-1p-ignore]::after {
          display: none !important;
      }
      
  2. Password Generation Length Constraints:

    • Laravel’s 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).
    • Fix: Use newPasswordLength(8) to enforce a custom length, even if maxLength is lower.
  3. Disabled State:

    • The copy-to-clipboard and generate buttons do not appear when the input is disabled (disabled: true). This is intentional but may surprise users.
    • Tip: Use disabled: false explicitly if these actions should remain available.
  4. Language Key Conflicts:

    • Overriding language keys (e.g., filament-password-input::password.actions.copy.tooltip) may conflict with Filament’s core translations if keys overlap.
    • Tip: Prefix custom keys with your app’s namespace (e.g., app::filament-password-input.copy.tooltip).
  5. Icon Customization:

    • Customizing icons via FilamentIcon::register() requires the exact alias names (e.g., filament-password-input::copy). Typos will result in missing icons.
    • Debug Tip: Check the Icons section of the README for the correct aliases.

Debugging Tips

  • 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.

Extension Points

  1. 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'));
    
  2. 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()
        );
    
  3. Custom Validation: Integrate with Laravel’s validation rules dynamically:

    Password::make('password')
        ->rules(fn (Password $component) => [
            'required',
            'min:8',
            'regex:/[A-Z]/', // Custom rule
        ]);
    
  4. 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.

Performance Quirks

  • 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.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
calmfox/watch-sylius
damienfern/grpc-symfony-bundle
atoolo/index-bundle
atoolo/genai-bundle
coprotoai/laravel-ticket
davidjln/llm-carbon-bundle
cryonighter/valid-request-bundle
coolms/taxonomy-bundle
coolms/field-bundle
articulate-orm/symfony
aaix/laravel-tall-architect
ephoto/akeneo-connector
emmanuelballery/eb-plantumlbundle
emielburgman/symfony-visitor-beacon
emielburgman/symfony-visit-storage
emielburgman/symfony-security-headers
emielburgman/symfony-log-viewer
emarref/xdebug-bundle
emarref/pubnub-bundle
elriseio/finance-money-bundle