Back to catalog
Component detail entry
Forms
@vean/ui
SPassword

Password

Password belongs to the Forms category. Start with demos and usage, then use the API tables to finish integration and styling decisions.

Use the quick jump panel to reach overview, usage, demos, and API first, then continue through the full page.

Quick jump

Related components

If you are composing interactions in the same family, these components usually pair well together.

Password

Overview

A password input field with a toggle button to show/hide the entered value. Use it for login forms, sign-up forms, or any sensitive credential entry. It composes the input family base with a visibility switch, and supports clearable mode. For non-sensitive text use SInput.

Usage

Features

  • 📏 6 sizes: xs, sm, md, lg, xl, 2xl (inherited from the input base)
  • 👁 Show/hide toggle with i18n aria-label and aria-pressed semantics
  • 🎛 Controlled / uncontrolled visible state (v-model:visible + defaultVisible)
  • 🧹 Clearable mode with an i18n aria-label clear button
  • 🔒 disabled / readonly guards across input, toggle, and clear elements
  • 📋 Native form submission via a proxied hidden input when name is set
  • 🧩 Custom visible slot for a bespoke toggle button
  • ♿ Full accessibility support — toggle naming, pressed state, axe-clean

Demos

Basic

Icon

API

Aria Layer

2

Password

25 Props3 Emits4 Slots
Props
PropTypeDefaultDescription
class
ClassValue
—
Additional class names applied to the root element.
size
ThemeSize
—
Visual size of the component.
ui
Partial<PasswordUi>
—
Per-slot class overrides for the component.
visible
boolean
—
Controlled password visibility.
defaultVisible
boolean
false
The initial visibility state when it is not controlled.
visibleProps
ButtonProps
—
Properties forwarded to the visible element.
inputRef
((el: HTMLInputElement) => void)
—
The function to set the input element.
clearable
boolean
false
Whether to show the clear trigger.
controlProps
InputControlProps
—
Properties forwarded to the control element.
clearProps
InputClearProps
—
Properties forwarded to the clear element.
defaultValue
string
—
The default value of the input
modelValue
string
—
The controlled value of the input
disabled
boolean
—
When `true`, prevents the user from interacting with the input.
readonly
boolean
—
When `true`, the input is read-only.
rootProps
BaseProps
—
Properties forwarded to the root element
name
string
—
The name of the field. Submitted with its owning form as part of a name/value pair.
required
boolean
—
When `true`, indicates that the user must set the value before the owning form can be submitted.
id
string
—
Id of the input element
autofocus
boolean
—
When `true`, the input is auto-focused.
autocomplete
'search' | 'name' | 'email' | 'tel' | 'url' | 'on' | 'off' | 'username' | 'current-password' | 'new-password' | 'one-time-code' | 'given-name' | 'family-name' | 'organization' | 'street-address' | 'address-level2' | 'postal-code' | 'country' | 'cc-name' | 'cc-number' | 'cc-exp' | 'cc-csc' | 'transaction-amount'
—
The autocomplete attribute of the input. Supports the HTML autofill tokens (including password-manager values such as `current-password` / `new-password`), in addition to the `on` / `off` switches.
maxlength
number
—
The maximum number of characters allowed in the input
minlength
number
—
The minimum number of characters allowed in the input
pattern
string
—
The pattern attribute of the input
placeholder
string
—
The placeholder of the input
type
InputTypeHTMLAttribute
—
The type of the input element.
Emits
Emit NameParametersDescription
update:modelValue
string
Emitted when the model value changes.
clear
PointerEvent
Emitted when the clear button is clicked.
update:visible
boolean
Emitted when the visible state changes.
Slots
Slot NameParametersDescription
leading
PasswordCompactSlotProps
Custom content for the leading slot.
trailing
PasswordCompactSlotProps
Custom content for the trailing slot.
clear
PasswordCompactSlotProps
Custom content for the clear slot.
visible
PasswordCompactSlotProps
Custom content for the visible slot.

PasswordCompact

22 Props3 Emits4 Slots
Props
PropTypeDefaultDescription
visible
boolean
—
Controlled password visibility.
defaultVisible
boolean
false
The initial visibility state when it is not controlled.
visibleProps
ButtonProps
—
Properties forwarded to the visible element.
inputRef
((el: HTMLInputElement) => void)
—
The function to set the input element.
clearable
boolean
false
Whether to show the clear trigger.
controlProps
InputControlProps
—
Properties forwarded to the control element.
clearProps
InputClearProps
—
Properties forwarded to the clear element.
defaultValue
string
—
The default value of the input
modelValue
string
—
The controlled value of the input
disabled
boolean
—
When `true`, prevents the user from interacting with the input.
readonly
boolean
—
When `true`, the input is read-only.
rootProps
BaseProps
—
Properties forwarded to the root element
name
string
—
The name of the field. Submitted with its owning form as part of a name/value pair.
required
boolean
—
When `true`, indicates that the user must set the value before the owning form can be submitted.
id
string
—
Id of the input element
autofocus
boolean
—
When `true`, the input is auto-focused.
autocomplete
'search' | 'name' | 'email' | 'tel' | 'url' | 'on' | 'off' | 'username' | 'current-password' | 'new-password' | 'one-time-code' | 'given-name' | 'family-name' | 'organization' | 'street-address' | 'address-level2' | 'postal-code' | 'country' | 'cc-name' | 'cc-number' | 'cc-exp' | 'cc-csc' | 'transaction-amount'
—
The autocomplete attribute of the input. Supports the HTML autofill tokens (including password-manager values such as `current-password` / `new-password`), in addition to the `on` / `off` switches.
maxlength
number
—
The maximum number of characters allowed in the input
minlength
number
—
The minimum number of characters allowed in the input
pattern
string
—
The pattern attribute of the input
placeholder
string
—
The placeholder of the input
type
InputTypeHTMLAttribute
—
The type of the input element.
Emits
Emit NameParametersDescription
update:modelValue
string
Emitted when the model value changes.
clear
PointerEvent
Emitted when the clear button is clicked.
update:visible
boolean
Emitted when the visible state changes.
Slots
Slot NameParametersDescription
leading
PasswordCompactSlotProps
Custom content for the leading slot.
trailing
PasswordCompactSlotProps
Custom content for the trailing slot.
clear
PasswordCompactSlotProps
Custom content for the clear slot.
visible
PasswordCompactSlotProps
Custom content for the visible slot.

Notes

Architecture and benchmark differences

VeanUI builds the password input by reusing the input family base: PasswordCompact composes InputRoot / InputControl / InputClear and adds a default visible slot backed by useControllableState. The styled layer extends inputVariants with a visible slot override styled as a mini icon button. This mirrors the headless/styled split of reka-ui and shadcn, differing from single-package libraries such as Element Plus.

CapabilityVeanUIreka-ui PasswordInputshadcnElement Plus el-input
Aria/styled split✅———
Controlled / uncontrolled visible✅✅——
Show/hide toggle (icon)✅✅✅✅
i18n toggle label✅——✅
aria-pressed semantics✅———
Clearable mode✅—✅✅
disabled / readonly guards✅✅✅✅
Size variants (xs…2xl)✅———
Custom visible slot✅———
Form proxying (hidden input)✅———

Cautions

  • The type prop is intentionally overridden by the visibility state (text when visible, password otherwise); a user-provided type is not honored.
  • The visible toggle button renders with type="button" to prevent accidental native form submission.
  • Cursor position and password-manager compatibility are guaranteed by the native input contract.

FAQ

How do I default the password to visible?

Pass defaultVisible (uncontrolled) or bind visible with v-model:visible (controlled).

How do I customize the toggle button?

Use the visible slot. It receives modelValue, visible, clear, and toggle props for full control.

How do I make the field clearable?

Pass clearable. The clear button clears the value and emits clear; it is disabled together with disabled / readonly.

Why does my type prop get ignored?

Password fields must switch between text and password to toggle visibility. The component owns this switch, so a user-provided type is overridden by design.

Changelog

Version history is grouped by release so you can quickly see what changed for this component across published versions.

v0.22.1

2026-05-14

Compare release

Feature

enhance PasswordCompact component with clear event and improved props

Scope: passwordAuthors: soybeanfeView commit6b9d0

v0.0.2

2025-11-18

Compare release

Feature

implement Password component with various examples including base, clearable, disabled, and icon visibility

Scope: passwordAuthors: soybeanjsView commit92544

Feature

implement Password component with various examples including base, clearable, disabled, and icon visibility

Scope: passwordAuthors: soybeanjsView commit92544