vael-ui v0.5.7

Forms & inputs

Layout

PasswordInput

A password field with a reveal button and a requirements hint. Use it on sign-up and sign-in forms.

Validating a form? vael-form wires this up with a schema

Install

import { PasswordInput } from 'vael-ui'

Playground

Placement, behaviour and animation

Usage
<script setup lang="ts">
import { ref } from 'vue'
import { PasswordInput } from 'vael-ui'

const value = ref('')
</script>

<template>
  <PasswordInput placeholder="Type here…" v-model="value" />
</template>

Props

NameTypeDefaultDescription
size'sm' | 'md' | 'lg''md'Control size.
disabledbooleanfalseDisables the input and reveal toggle. A disabled parent Field also disables it.
readonlybooleanfalseMakes the value read-only while keeping it focusable and selectable.
invalidbooleanfalseStandalone override; ORed with the nearest Field's error state.
placeholderstringText shown while the input is empty.
namestringNative name on the input, for plain <form> submission.
autocompletestringTells password managers what this field is. Defaults to 'new-password' when the field shows requirements (rules or #hint), so the phone offers a strong password, and to 'current-password' otherwise, so a saved one fills in. Set it for a case that reads otherwise, like a sign-up form without rules.
revealablebooleantruefalse hides the reveal toggle, for forms that must never show the password in plain text.
rulesPasswordRule[]Requirement checks ({ label, test }) for the hint checklist and the #hint slot's results. There are no built-in rules; without rules or #hint, the hint doesn't render.
hintPlacement'inline' | 'none' | 'popover''popover'Where the requirements hint renders. 'none' disables it outright.
motionPasswordInputMotiontrueHow it moves: its appearance ({ initial: { root: { opacity: 0, y: 4 } } }) and its states ({ states: { invalid: { root: { x: [0, -6, 6, 0] } } } }). The inline hint is a part; the popover one is not. false skips the inline hint's enter/exit transition.
side'top' | 'right' | 'bottom' | 'left'Which side of the input the hint appears on, in both 'popover' and 'inline' mode. Inline defaults to 'bottom'.
align'start' | 'end' | 'center'How the hint aligns against the input along that side, in both 'popover' and 'inline' mode. Inline defaults to 'start'.
sideOffsetnumberGap between the input and the hint popover, in pixels. Popover mode only.
alignOffsetnumberShifts the hint popover along the alignment axis, in pixels. Popover mode only.
panelWidthPanelWidthThe hint popover's width: 'trigger' for at least the input's width, or a width in px or any CSS length ('20rem'). Unset, it fits its rules, up to 16rem. Popover mode only.
teleportTostring | HTMLElementTeleport target for the hint popover: a CSS selector or element. Popover mode only.
forceMountbooleanfalseKeeps the hint popover mounted (toggled with v-show) and skips the built-in transition. Popover mode only.
beforeCloseBeforeClose<PopoverCloseReason>Runs before the hint closes. Return true to close it, false to keep it open, or a promise of either, like () => confirmAction(…).result. The hint stays open while the promise is pending. Popover mode only.
uiPartial<Record<'root' | 'frame' | 'input' | 'toggle' | 'hint' | 'hintList' | 'hintItem' | 'hintIcon', UiPartValue>>Class and style overrides for each part.
modelValuestring''Password value.
visiblebooleanfalseWhether the password is shown as plain text.

Events

NameTypeDescription
update:modelValue(value: string)Fires when modelValue changes (v-model).
update:visible(value: boolean)Fires when visible changes (v-model:visible).

Slots

NameTypeDescription
endanyInline trailing content, placed before the reveal toggle.
display{ value: string; placeholder: string; focused: boolean; }Draws the text yourself over the field's own text, as Input's #display: the real input keeps the caret, selection and screen reader text.
hint{ value: string; results: PasswordRuleResult[]; }Replaces the default requirements checklist. Falls back to it when omitted.

Exposed

NameTypeDescription
elHTMLElement | nullRoot element.
inputElHTMLInputElement | nullNative <input> element.
visiblebooleanWhether the password is shown as plain text (writable).
hintPanelElHTMLElement | nullHint popover panel element (null while closed or in 'inline' mode).
closeHint() => voidCloses the hint popover, running beforeClose if set.
cancelCloseHint() => voidAborts a pending beforeClose exit and keeps the hint popover open.
partsRecord<string, HTMLElement | HTMLElement[] | null>Its elements by part name, for your own animation; a repeated part is an array.

Motion New

PasswordInput: its appearance and states.

<PasswordInput
  :motion="{ states: { invalid: { root: { scale: 1.04 } } } }"
/>
NameTypeDescription
initialexitrootinputtogglehintSets where each part comes in from and leaves to: any CSS property, plus x, y and blur. A plain number is px, or degrees for rotate.
statesinvaliddisabledfocusSets values per part that hold while a state is on. An array is a set of keyframes that plays once as the state turns on, such as a shake on invalid.
enterleave(parts, context) => animationAnimates the parts with GSAP, motion or element.animate(). Return the animation and the component waits for it, and stops it if interrupted.
springdurationeasing{ damping, response } | number | stringTimes all of it: a spring, or a duration in ms with an easing. Never both.
falsebooleanTurns its motion off, for an animation of your own on its exposed elements.

Accessibility

KeyAction
TabMoves focus from the input to the show and hide button.
EnterSpaceShows or hides the password when the button has focus.
  • The show and hide button is labeled “Show password” or “Hide password” to match the current state.
  • The requirements list describes the input through aria-describedby, and each requirement reads as met or not met. As you type, a polite live region announces only the requirements that changed.
  • In hintPlacement="popover", the list opens when the input takes focus and closes when it loses focus.
  • It is built on Input, so Field labels it the same way.