Skip to main content
Copy for LLM

Password Input

The <x-wirekit::password-input> component extends the standard text input with a visibility toggle (eye icon) and an optional password strength meter. The toggle switches between type="password" and type="text" via Alpine.js without re-rendering.

Basic Usage

Password with Toggle

Without Toggle

Toggle Disabled

When toggle is false, the eye icon button is not rendered and the input behaves like a standard password field.

With Strength Meter

Strength Meter Enabled

Use at least 8 characters with a mix of letters, numbers, and symbols.

The strength meter scores the password in the browser as it is typed and fills one to four bars below the field. It counts four things, one point each: eight characters or more, upper- and lowercase letters, a digit, and a character that is neither a letter nor a digit.

  • Weak — one point or none
  • Fair — two points
  • Good — three points
  • Strong — all four

It counts kinds of characters and nothing else. It knows no list of common passwords, so Password1! reads Strong. Check the password on the server, with Laravel's Password rule and its uncompromised() check for instance, and treat the meter as a hint while the reader types.

The same bars are available without a field as Strength Meter, for a strength your application computes, such as that of a generated code.

An x-model of yours binds the password with the meter on as it does without it: the component hands the value the meter reads to your binding, so your model, the meter and the field always hold the same text.

Size Variants

Three Sizes

Error State

Password input with an error message

Password must be at least 8 characters.

Width

A form component fills the width of the block it stands in, so its width is the width you give the parent; in a flex row it takes the room its content asks for instead:

<div class="max-w-sm">
    <x-wirekit::password-input label="Password" name="password" />
</div>

See Input — Width for more layout examples (grid columns, mixed widths).

Optimistic UI

Pass the name of the Livewire method the field should call and the value is sent when you leave the field, shown as saving while it goes:

<x-wirekit::password-input
    name="secret"
    autocomplete="new-password"
    label="New password"
    optimistic="savePassword"
/>

Load wirekit-optimistic.js alongside whichever bundle you already use — below it, in your layout:

@wirekitScripts
<script src="{{ asset('vendor/wirekit/wirekit-optimistic.js') }}" defer></script>

Try it

The demo below runs the real path: the change shows immediately, the outline says it is provisional, and the server's answer either confirms it silently or takes it back.

Optimistic password field — accepted, refused, and a slow answer

The <livewire:demos.…> wrapper above exists only on this site — it supplies the demo methods so the page can show a real round trip. The block under it is what you write.

A refusal does not take your value back. For a toggle or a select, putting the old value back costs you nothing — it is simply the other choice. Here it would delete what you typed because a save failed, and re-typing a password is the most expensive re-entry any field can ask for. The value stays, and you are told two things: that it did not save, and that it is still there.

Nothing reads your password back. The announcements name no value, and none is written into the page's markup either — the field is driven by the property it already owns rather than by a value handed to the script.

The field is not marked invalid. aria-invalid means this value is wrong, and a save that failed on the network says nothing about the value.

Required Fields

A required field the reader leaves empty is marked red once they try to submit — the same way every other WireKit field is, because the styling lives on the shared wk-field class rather than in each component's own class list.

A required password field

It uses :user-invalid, not :invalid. The difference is when it fires: :user-invalid waits until the reader has interacted with the control or tried to send the form, so an empty form does not arrive painted red. Once it is red, the browser's message stands under the field and says why, until the value is valid.

The mark is the browser's judgment, not a validation result of yours. For a rule the browser cannot check — a password that is too short for your policy, one that does not match its confirmation — pass the message through error, which paints the same border and announces it.

A form in which every field is required needs no asterisk. :required-mark="false" leaves it out of the label and keeps required, so the browser still checks the field, marks it red and says why:

<x-wirekit::password-input name="passphrase" label="Passphrase" required :required-mark="false" />

Props

Prop Type Default Description
label string|null null Label text above the input
hideLabel bool false Render the label visually hidden (sr-only) but keep it for assistive tech — for a compact field in a toolbar or header
requiredMark bool true Whether the label of a field written with required draws its indicator (*). false keeps required and the browser's check and leaves the mark out, for a form in which every field is required.
hint string|null null Help text below the input
help string|null null An explanation of the field, shown in a tooltip from a question mark beside the label and read as the field's description. Needs a label to stand beside. See Help beside the label
error string|false|null null Error message (also reads from $errors). false shows none and leaves the $errors bag alone, see Turning an Error Off
autocomplete string|false current-password Which password this field holds. Pass new-password on a registration or change-password form — three identical-looking fields are where an autofill heuristic guesses wrong. false omits the attribute for a field that is not a credential (WCAG 1.3.5)
name string|null null Form field name
id string|null auto-generated Element id
size string 'md' 'sm', 'md', 'lg'
toggle bool true Show the show/hide password toggle button
strengthMeter bool false Show password strength meter below input
optimistic string|null null Livewire method to call when you leave the field, showing the change before the server answers
optimisticArgs array [] Extra arguments appended to the optimistic action call, after the new value — the row this control belongs to.
disabled bool false Disables the field and its show-password button
scope string|null null Scoped personalization key
announceError bool|null null Render the error message in an aria-live="polite" region so a validation error that appears after render reaches a screen reader. Precedence: this prop, then the parent <x-wirekit::form :announce-errors>, then config('wirekit.a11y.announce_error'). Set false when the page runs its own live region.

Slots

Slot Description
labelAfter Markup after the label and its help question mark, in the same row and outside both, such as a badge that says a setting is not decided yet. See A Mark After the Label.

Accessibility

  • Uses native <input type="password"> — inherits browser autofill and AT support
  • The toggle button is named after the field it reveals, "Show New password" and "Hide New password" on a field labeled New password, so a form with a password and its confirmation does not offer two buttons with one name. A field with neither label nor aria-label reads "Show password" and "Hide password". The name changes with the state, and it is the one place the state is reported: a pressed state beside it would report it twice, and "Hide password, pressed" leaves open whether the password is shown
  • Toggle icons (eye / eye-off) are aria-hidden="true"
  • Strength meter bar uses role="meter" with aria-valuenow, aria-valuemin="0", aria-valuemax="4", aria-label="Password strength", and an aria-valuetext that names the level in words rather than as a number
  • While the field is empty the meter carries no aria-valuetext at all, rather than an empty one. There is no verdict to announce on a password nobody has typed, and aria-valuetext is read instead of the number — so an empty value leaves it to the reader's software whether to fall back to aria-valuenow="0" or to say nothing
  • Strength level text ("Weak password" … "Strong password") sits in a visually-hidden aria-live="polite" region, so the score reaches a screen reader instead of being carried by the bar colors alone — it is also what the field's aria-describedby points at
  • Under a forced-colors theme, such as Windows High Contrast, the meter's lit bars take the theme's selection color and the unlit ones an edge in its text color. The bars are where a sighted reader sees the strength, so they keep it where the theme repaints their colors
  • aria-invalid="true" with an error, and aria-describedby naming the error or, without one, the hint

Keyboard Interaction

Key Action
Tab Move focus to the input
Any character Insert the character (rendered as a masked dot when masked)
Tab (twice) Move focus to the show/hide toggle button
Enter / Space (on toggle) Toggle masked / plain rendering

Pitfalls

  • Don't disable the show-password toggle for "security." Hiding the toggle reduces password quality more than it adds security (cognitive load drives users to weak choices).
  • Don't omit autocomplete="current-password" / "new-password". Browsers and password managers use these to populate correctly; missing values block manager auto-fill.

Design Tokens

Token Purpose
--color-wk-bg-input Input background
--color-wk-border-strong Default border color, and the edge of an unlit strength bar
--color-wk-border-error Border color on error
--color-wk-text Input text color
--color-wk-text-muted Toggle button icon color
--color-wk-text Toggle button icon color on hover
--color-wk-ring Focus ring color
--color-wk-danger-text Strength meter — weak
--color-wk-warning-text Strength meter — fair and good
--color-wk-success-text Strength meter — strong
--size-wk-sm / md / lg Input height per size variant
--radius-wk-md Border radius
--transition-wk-duration Toggle + meter transition speed

Customization

Override defaults in config/wirekit.php:

'components' => [
    'password-input' => ['size' => 'md', 'toggle' => true, 'strength-meter' => false],
],

Further Reading

Updated in WireKit v2.74.0 (2026-11-24)

Was this page helpful?

Thank you for your feedback!

Voting requires cookies or local storage. What we store