Inline visibility button
Live inline visibility button example with accessible visibility controls and copyable component code.
<TogglePassword
name="toggle-password-1"
value="Northstar!2026"
maxlength="128"
fields='[]'
/>
// Generated by scripts/generate-showcase.mjs. Do not edit directly.
page TogglePasswordDetail {
layout = "showcase"
state playground_size = ctx.url.searchParams.get("pg_size") ?? "default"
state playground_color = ctx.url.searchParams.get("pg_color") ?? "primary"
state playground_label = ctx.url.searchParams.get("pg_label") ?? "Password"
state playground_name = ctx.url.searchParams.get("pg_name") ?? "toggle-password-1"
state playground_value = ctx.url.searchParams.get("pg_value") ?? "Northstar!2026"
state playground_placeholder = ctx.url.searchParams.get("pg_placeholder") ?? "Enter your password"
state playground_autocomplete = ctx.url.searchParams.get("pg_autocomplete") ?? "current-password"
state playground_minlength = ctx.url.searchParams.get("pg_minlength") ?? ""
state playground_maxlength = ctx.url.searchParams.get("pg_maxlength") ?? "128"
state playground_pattern = ctx.url.searchParams.get("pg_pattern") ?? "(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[^A-Za-z0-9]).{8,}"
state playground_fields = ctx.url.searchParams.get("pg_fields") ?? "[]"
state playground_visible = ctx.url.searchParams.get("pg_visible") ?? "false"
state playground_toggleable = ctx.url.searchParams.get("pg_toggleable") ?? "true"
state playground_toggleMode = ctx.url.searchParams.get("pg_toggleMode") ?? "button"
state playground_checkboxLabel = ctx.url.searchParams.get("pg_checkboxLabel") ?? "Show password"
state playground_showLabel = ctx.url.searchParams.get("pg_showLabel") ?? "Show password"
state playground_hideLabel = ctx.url.searchParams.get("pg_hideLabel") ?? "Hide password"
state playground_disabled = ctx.url.searchParams.get("pg_disabled") ?? "false"
state playground_readonly = ctx.url.searchParams.get("pg_readonly") ?? "false"
state playground_required = ctx.url.searchParams.get("pg_required") ?? "false"
state playground_invalid = ctx.url.searchParams.get("pg_invalid") ?? "false"
state playground_helpText = ctx.url.searchParams.get("pg_helpText") ?? ""
state playground_validationMessage = ctx.url.searchParams.get("pg_validationMessage") ?? ""
state playground_class = ctx.url.searchParams.get("pg_class") ?? ""
seo {
title = "Toggle Password"
description = "Accessible password field with optional show and hide controls."
}
view {
Accessible password field with optional show and hide controls. Change any prop and inspect the server-rendered component immediately.Toggle Password
Configure Toggle Password
<TogglePassword
name="toggle-password-1"
value="Northstar!2026"
maxlength="128"
fields='[]'
/>
Compare configurations and resize the browser to check responsive behavior.
Live inline visibility button example with accessible visibility controls and copyable component code.
<TogglePassword
name="toggle-password-1"
value="Northstar!2026"
maxlength="128"
fields='[]'
/>
Live checkbox-controlled toggle example with accessible visibility controls and copyable component code.
<TogglePassword
label="Checkbox-controlled toggle"
name="toggle-password-2"
value="Northstar!2026"
maxlength="128"
fields='[]'
toggleMode="checkbox"
/>
Live synchronized password fields example with accessible visibility controls and copyable component code.
<TogglePassword
label="Passwords"
name="toggle-password-3"
maxlength="128"
fields='[
{
"label": "New password",
"name": "new-password",
"placeholder": "Enter new password",
"autocomplete": "new-password"
},
{
"label": "Current password",
"name": "current-password",
"value": "Northstar!2026",
"autocomplete": "current-password"
}
]'
/>
Live without visibility toggle example with accessible visibility controls and copyable component code.
<TogglePassword
label="Without visibility toggle"
name="toggle-password-4"
maxlength="128"
fields='[]'
toggleable="false"
/>
Live supporting help text example with accessible visibility controls and copyable component code.
<TogglePassword
label="Supporting help text"
name="toggle-password-5"
maxlength="128"
fields='[]'
helpText="Use at least eight characters and avoid passwords used on other sites."
/>
Live required validation example with accessible visibility controls and copyable component code.
<TogglePassword
label="Required validation"
name="toggle-password-6"
minlength="8"
maxlength="128"
fields='[]'
required="true"
/>
Live disabled password example with accessible visibility controls and copyable component code.
<TogglePassword
label="Disabled password"
name="toggle-password-7"
maxlength="128"
fields='[]'
disabled="true"
/>
Live read-only password example with accessible visibility controls and copyable component code.
<TogglePassword
label="Read-only password"
name="toggle-password-8"
value="Northstar!2026"
maxlength="128"
fields='[]'
readonly="true"
/>
Live large password field example with accessible visibility controls and copyable component code.
<TogglePassword
size="lg"
label="Large password field"
name="toggle-password-9"
maxlength="128"
fields='[]'
/>
Live toggle events example with accessible visibility controls and copyable component code.
<TogglePassword
label="Toggle events"
name="toggle-password-10"
maxlength="128"
fields='[]'
/>
Public events declared by this component. Custom events bubble from the component root and expose state through event.detail.
@inputFires immediately as the component value changes.@changeFires when the component value or selection changes.@toggleFires when the component toggles between states.const component = document.querySelector('[data-wrn-events]')
component.addEventListener('input', (event) => {
console.log(event.detail)
})All content and behavior shown above is supplied through these props and slots.
| Prop | Type | Default | Required |
|---|---|---|---|
size | string | "default" | No |
color | string | "primary" | No |
label | string | "Password" | No |
name | string | "password" | No |
value | string | "" | No |
placeholder | string | "Enter your password" | No |
autocomplete | string | "current-password" | No |
minlength | string | "" | No |
maxlength | string | "" | No |
pattern | string | "(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[^A-Za-z0-9]).{8,}" | No |
fields | string | [] | No |
visible | boolean | false | No |
toggleable | boolean | true | No |
toggleMode | string | "button" | No |
checkboxLabel | string | "Show password" | No |
showLabel | string | "Show password" | No |
hideLabel | string | "Hide password" | No |
disabled | boolean | false | No |
readonly | boolean | false | No |
required | boolean | false | No |
invalid | boolean | false | No |
helpText | string | "" | No |
validationMessage | string | "" | No |
class | string | "" | No |