The Password component provides a specialized input field for entering passwords with features such as revealing/hiding the password and a password generator.
use TallStackUIFilament\Forms\Components\Password;
Password::make('password')
->label('Password'),Enable a password generator to help users create strong passwords:
Password::make('password')
->generator(), // Adds a button to generate random passwordsYou can use a closure to conditionally enable the generator:
Password::make('password')
->generator(fn () => auth()->user()->is_admin),Define password strength rules that will be checked as the user types:
Password::make('password')
->passwordRules(['min:8', 'symbols:!@#', 'numbers', 'mixed']),You can use a closure for dynamic rules:
Password::make('password')
->passwordRules(fn () => [
'min:8',
// ...
]),Add a placeholder to guide users:
Password::make('password')
->placeholder('Enter a strong password...'),use TallStackUIFilament\Forms\Components\Password;
Password::make('password')
->label('New Password')
->generator()
->passwordRules([
'min:8',
'symbols:!@#',
'numbers',
'mixed',
])
->placeholder('Create a strong password')
->required(),Add validation rules as needed:
Password::make('password')
->required()
->minLength(8),
use Illuminate\Validation\Rules\Password as PasswordRule;
Password::make('password')
->required()
->rule(PasswordRule::min(8)
->letters()
->numbers()
->symbols()
->uncompromised()),Add custom HTML attributes to the input element:
Password::make('password')
->extraInputAttributes([
'autocomplete' => 'new-password',
'data-analytics-id' => 'password-field',
]),