Veil UI
Components

Password Input

A password field with a show and hide toggle.

Installation

$ npx veil-ui@latest add password-input

Usage

import { PasswordInput } from "@/components/ui/password-input";

<PasswordInput
  placeholder="Enter your password"
  autoComplete="current-password"
  aria-label="Password"
/>;

Examples

Basic

With label and hint

Use a mix of letters, numbers and symbols.

Disabled

API reference

PropTypeDefaultDescription
typepassword | text—Managed internally. Starts as password and switches while revealed.
valuestring—Controlled field value.
onChangeReact.ChangeEventHandler<HTMLInputElement>—Called whenever the field value changes.
...propsReact.ComponentProps<"input">—All native input attributes.

Accessibility

  • The reveal control is a real button with a changing accessible name: “Show password” / “Hide password”.
  • It also reports aria-pressed, so the current visibility is announced.
  • Pair the field with a visible <Label> or pass aria-label.

Vue and plain HTML

This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add password-input --framework vue or switch the framework in components.json.

<script setup lang="ts">
import { Eye, EyeOff } from "lucide-vue-next";
import { ref } from "vue";

import { Input } from "@/components/ui/input";
import { cn } from "@/lib/utils";

defineOptions({ inheritAttrs: false });

const props = defineProps<{ class?: string }>();

const visible = ref(false);
</script>

<template>
  <div class="relative w-full">
    <Input
      v-bind="$attrs"
      :type="visible ? 'text' : 'password'"
      :class="cn('pr-10', props.class)"
    />
    <button
      type="button"
      :aria-label="visible ? 'Hide password' : 'Show password'"
      :aria-pressed="visible"
      class="absolute right-1 top-1/2 inline-flex size-7 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50"
      @click="visible = !visible"
    >
      <EyeOff v-if="visible" class="size-4" aria-hidden="true" />
      <Eye v-else class="size-4" aria-hidden="true" />
    </button>
  </div>
</template>

On this page