Appearance
zk-password
Renders a password input with configurable minimum length and an optional show/hide toggle driven by vanilla JS — no external dependency required.
Props
All zk-input props are accepted and forwarded. Additional props:
| Prop | Type | Default | Description |
|---|---|---|---|
min | int | config('blade-components.password.min_characters', 8) | Minimum character length enforced via pattern |
showToggle | bool | config('blade-components.password.show_toggle', true) | Render a show/hide toggle button |
Named slots
| Slot | Description |
|---|---|
iconShow | Icon displayed when password is hidden (click to reveal). Overrides config default. |
iconHide | Icon displayed when password is visible (click to conceal). Overrides config default. |
Slots accept any content: emoji, SVG, icon font markup, plain text.
Config
php
// config/blade-components.php
'password' => [
'min_characters' => 8,
'show_toggle' => true,
// Defaults reference the icon sprite shipped with the package
// (resources/views/icons/sprite.blade.php, injected once per page).
'icon_show' => '<svg width="20" height="20"><use href="#icon-visibility"></use></svg>',
'icon_hide' => '<svg width="20" height="20"><use href="#icon-visibility-off"></use></svg>',
],Priority: named slot > app config > component default (emoji).
Examples
Basic
blade
<x-zk-password name="password" label="Password" required />Confirm password (no toggle)
blade
<x-zk-password
name="password_confirmation"
label="Confirm password"
:showToggle="false" />Custom minimum length
blade
<x-zk-password name="password" label="Password" :min="12" required />Custom icons via named slots
blade
{{-- Material Symbols --}}
<x-zk-password name="password" label="Password">
<x-slot name="iconShow"><span class="msr">visibility</span></x-slot>
<x-slot name="iconHide"><span class="msr">visibility_off</span></x-slot>
</x-zk-password>
{{-- Font Awesome --}}
<x-zk-password name="password" label="Password">
<x-slot name="iconShow"><i class="fa-regular fa-eye"></i></x-slot>
<x-slot name="iconHide"><i class="fa-regular fa-eye-slash"></i></x-slot>
</x-zk-password>
{{-- SVG --}}
<x-zk-password name="password" label="Password">
<x-slot name="iconShow"><svg>...</svg></x-slot>
<x-slot name="iconHide"><svg>...</svg></x-slot>
</x-zk-password>Global icon override via config
php
// config/blade-components.php — applies to every x-zk-password in the app
'password' => [
'icon_show' => '<span class="msr">visibility</span>',
'icon_hide' => '<span class="msr">visibility_off</span>',
],Notes
The toggle is driven by an inline vanilla JS snippet injected once per page via
@once— no Alpine.js or other external dependency needed.The icon sprite (
icons.sprite) is injected once per page via its own@once, regardless of how manyx-zk-passwordfields are on the page.data-icon-showis visible when the field is intype="password"state;data-icon-hidewhen intype="text".The toggle button uses
data-label-show/data-label-hidefor i18naria-label(translated in 21 languages).The generated
patternis^.{N,}$where N is theminvalue.Internally the button renders via
x-form.input'strailingContentprop (raw HTML, scoped strictly to[data-input]) rather thaniconAfter—iconAfteris also mirrored intox-form.label, which would duplicate an interactive button into the<label>element. Consuming apps should position[data-toggle-visibility]relative to[data-password-toggle] [data-input], not the outer[data-password-toggle]wrapper, so it stays aligned with the input regardless of a validation message rendered below it.Browser gotcha: the sprite's
<path fill="currentColor">is a presentation attribute, and it does not reliably resolve through<symbol>/<use>in Chromium — it can render as plain black regardless of the ambient inherited color, independently of whether that color itself is correct. Consuming apps must add an explicit CSS rule to actually get the intended color:css[data-toggle-visibility] svg, [data-toggle-visibility] use { fill: currentColor; }Set alongside an explicit
coloron[data-toggle-visibility]itself (all: unsetresets from a plain CSS reset — seeapp.scss— resets color toinherit, which without an explicit value drifts to whatever the ambient text color happens to be, not necessarily readable against the input's background).