WlPasswordInput

Password field with a show/hide button.
Components / Inputs v0.1.0

Change props to see the result: the example and code use the same settings. “Reset” restores the initial values.

Settings

size

Field size.

density

Density.

placeholder

Placeholder; falls back to WlConfig.locale.password (Password in English).

ariaLabel

Input aria-label.

strength
Not set

Consumer-provided password-strength status.

strengthLabel

Readable description of the password-strength status.

Error state.

Disables the field.

Props pt, models, handlers and slots can be edited in the SFC. See their descriptions in API.

Example

Focus: outside the example · pointer: outside the example

Explore the live example and copy its Vue SFC into your application. Settings on the left can be combined.

Code for your application

Vue SFC · current settings
<script setup lang="ts">
import { WlPasswordInput } from "legato-ui";
import { ref } from "vue";
const value = ref("Example123!");
</script>

<template>
  <div class="wl-stack" data-space="md">
    <WlPasswordInput
      v-model="value"
      aria-label="Password"
      autocomplete="new-password"
      
    />
  </div>
</template>

Password visibility and validation

Sizes and compact density, visibility toggle, application-side length validation and a disabled field.

Sizes and password visibility

The Show password button changes only visibility. The model value stays the same.

Application validation and disabled

This is an example rule, not built-in password strength validation.

Characters entered: 0. The password itself is not shown in messages.

Vue SFC · additional example
<script setup lang="ts">
import { WlButton, WlField, WlPasswordInput } from "legato-ui";
import { ref } from "vue";
const password = ref("");
const touched = ref(false);
</script>

<template>
  <div class="wl-stack" data-space="xl" data-input-example="WlPasswordInput">
    <section class="wl-stack" data-space="md">
      <h3 class="wl-text-title">{{ "Sizes and password visibility" }}</h3>
      <div class="wl-grid" data-space="lg">
        <WlField
          v-for="size in ['sm', 'md', 'lg'] as const"
          :id="`docs-password-${size}`"
          :key="size"
          v-slot="{ id }"
          :label="`${'Password, '}${size}`"
        >
          <WlPasswordInput
            :id="id"
            v-model="password"
            :size="size"
            autocomplete="new-password"
          />
        </WlField>
        <WlField id="docs-password-compact" v-slot="{ id }" label="Compact password input"><WlPasswordInput
          :id="id"
          v-model="password"
          density="compact"
          autocomplete="new-password"
        /></WlField>
      </div>
      <p class="wl-text-small wl-text-muted">{{ "The Show password button changes only visibility. The model value stays the same." }}</p>
    </section>
    <section class="wl-stack" data-space="md">
      <h3 class="wl-text-title">{{ "Application validation and disabled" }}</h3>
      <div class="wl-grid" data-space="lg">
        <WlField
          id="docs-password-validation"
          v-slot="{ id, ariaDescribedby, invalid }"
          label="Password with validation"
          :error="touched && password.length < 8 ? 'At least 8 characters required.' : undefined"
          hint="This is an example rule, not built-in password strength validation."
        >
          <WlPasswordInput
            :id="id"
            v-model="password"
            :invalid="invalid"
            :aria-describedby="ariaDescribedby"
            autocomplete="new-password"
            @blur="touched = true"
          />
        </WlField>
        <WlField id="docs-password-disabled" v-slot="{ id }" label="Disabled password">
          <WlPasswordInput :id="id" model-value="Example-secret" disabled />
        </WlField>
      </div>
      <div class="wl-inline" data-space="sm">
        <WlButton size="sm" @click="touched = true">{{ "Check length" }}</WlButton>
        <WlButton size="sm" @click="password = ''; touched = false">{{ "Clear password" }}</WlButton>
      </div>
      <p class="wl-text-small" role="status">{{
        "Characters entered:"
      }} {{
        password.length
      }}{{
        ". The password itself is not shown in messages."
      }}</p>
    </section>
  </div>
</template>