Switch between password & text

From password to text & vice versa

Upgrade your password field to toggle between text and password.

composer require symfony/ux-toggle-password
// ... use statements hidden - click to show
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\FormBuilderInterface;

class TogglePasswordForm extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->add('email', EmailType::class)
            ->add('password', PasswordType::class, [
                'toggle' => true,
            ])
        ;
    }
}
{% extends 'base.html.twig' %}

{% block body %}
    {{ form_start(form) }}
    {{ form_row(form.email) }}
    {{ form_row(form.password) }}
    <button type="submit" class="btn btn-primary">Login</button>
    {{ form_end(form) }}
{% endblock %}
Symfony logo

UX Toggle Password

Install It

$ composer require symfony/ux-toggle-password