Skip to content
Bladewell

<x-widget.password>

Password Blade component for Laravel and Livewire

A password field with a show/hide button and a Caps Lock warning. For new passwords, a live checklist of your rules. Never renders the value back into the page. Works with Livewire wire:model.

php artisan bladewell:add password
Also adds
Icon
Works with
Laravel 12 and 13, Livewire 3 and 4, Tailwind CSS 4.1+, PHP 8.3+
Guides
Two-factor authentication screens for Laravel Fortify · Passkey sign-in for Laravel with Fortify

Usage

Livewire

In a Livewire component, bind with wire:model; no name is needed, and the new-password checklist works the same. The password is never written into the HTML, Livewire renders included, so it can't leak into a page snapshot. Clear the property after saving ($this->reset('password', 'password_confirmation')), so it isn't kept in the component's state.

Blade
<form wire:submit="updatePassword" class="space-y-5">
    <x-widget.password label="Current password" wire:model="current_password" />

    <x-widget.password label="New password" new :min="8" numbers symbols wire:model="password" />

    <x-widget.password label="Confirm password" wire:model="password_confirmation" autocomplete="new-password" />

    <button type="submit">Update password</button>
</form>

On the server

The password can't stop a request that skips it. Here's what to check on your server, and what to keep cheap.

Security

  • Store only a hash: Hash::make() or the hashed cast, never the password itself, and keep it out of logs, the cache and email. For a new app, consider Argon2id (HASH_DRIVER=argon2id, where your PHP has it), OWASP's first choice; bcrypt, Laravel's default, is still fine at cost 12 or more.

    OWASP: Password storage · Laravel: Hashing

  • With new, the checklist only guides typing: a request can send any value. Enforce the same rules with Password::defaults() in your Form Request, and consider ->uncompromised() to turn away passwords already seen in a breach.

    Laravel: Validating passwords

  • Consider throttling sign-in and password reset by email and by IP, so passwords can't be guessed at speed, and answering the same whether or not the account exists.

    OWASP: Authentication · Laravel: Rate limiting

Server cost

  • Hashing is slow on purpose, so check a password once at sign-in and keep the session; don't re-hash on every request. ->uncompromised() calls an outside API on each submit: keep it to forms that set a new password.

    Laravel: Hashing

Examples

Password

Signing in: the eye button shows the password, and a note appears while Caps Lock is on. Creating one: new sets autocomplete="new-password" and shows your rules as a checklist; match them to your Form Request, e.g. Password::min(12)->mixedCase()->numbers(). :toggle="false" hides the eye button.

  • At least 12 characters
  • Upper and lower case letters
  • A number
  • A symbol
Show code
Blade
<div class="grid gap-6 sm:grid-cols-2">
    <x-widget.password name="password" label="Password" placeholder="Enter password" />
    <x-widget.password name="new_password" label="New password" new :min="12" mixed-case numbers symbols />
</div>

Props

Other attributes, such as autocomplete or data-*, are passed through to the element. class styles the component's outer wrapper.

<x-widget.password>

Prop Default Description
name null What it submits as. Never filled back into the page, Livewire included. Optional with wire:model.
id null Defaults to one made from the name (or the wire:model property).
label null Shown above the field, and its name for screen readers.
placeholder null Shown while it's empty.
error null An error message of your own; otherwise the validation error for the name, from the session or Livewire.
info null A hint under the field.
bag 'default' Which error bag to read the error from.
disabled false Greyed out: it can't be changed.
readonly false Shown, and submitted, but it can't be edited.
autocomplete null Defaults to current-password, or new-password with new.
new false For choosing a password: new-password autocomplete and a live checklist of the rules below.
toggle true A button to show or hide what's typed.
min 8 With new: the minimum length in the checklist.
letters false With new: requires a letter, and lists it.
mixed-case false With new: requires upper and lower case.
numbers false With new: requires a number.
symbols false With new: requires a symbol.

Accessibility

The example above is checked with axe-core against the WCAG 2.2 A and AA rules, in the light theme and the dark one, both as the page draws and with each popover, dialog, toast and tooltip opened, on every change. A change that fails can't be merged. Where axe can't decide, such as contrast on SVG text, the test measures the colours itself instead of letting it pass.

Automated checks can't judge everything: how it sounds in a screen reader, and how it feels to use from the keyboard, still need a person. Check those on your own pages too.

Source

What bladewell:add password writes to your app with the default namespaces. Prefer to copy by hand? Take these files, plus the ones from the components it also adds and Field, and the theme and base CSS.

resources/views/components/widget/password/index.blade.php Show
index.blade.php
resources/js/widget/password/index.js Show
index.js
app/View/Widget/ElementIds.php Show
ElementIds.php
app/View/Widget/FormField.php Show
FormField.php