ViraStack
  • Academy
  • About
  • Support
HomeGet StartedExamples
ViraStack

A frontend ecosystem: free guides, project templates, AI rules, and form components.

Products

  • ViraStack Start
  • ViraStack AI
  • ViraStack Mask
  • ViraStack Password
  • ViraStack Guide

Explore

  • Academy
  • About
  • Brand
  • Support

© 2026 ViraStack.

Open source · MIT

Examples

  • All
  • Basic
  • Confirm password
  • Custom icons
  • Custom text
  • Disabled / readOnly
  • Leaked passwords
  • Personal info
  • Programmatic
  • Prop merge
  • React Hook Form + Zod
  • Server Action
  • Show / hide
  • Sign-up with Mask
  • Strength meter

Confirm password

A repeat field with matchWith; matches is true, false or null.

← All examples·confirm

Preview

Repeat the password.

// components/new-password-fields.tsx
"use client";
 
import { useState } from "react";
 
import { useViraPassword } from "@virastack/password";
 
export function NewPasswordFields() {
  const [password, setPassword] = useState("");
 
  const { inputProps, btnProps } = useViraPassword({
    inputProps: { value: password, onChange: (event) => setPassword(event.target.value) },
  });
  // Same hook with matchWith. Each field keeps its own show/hide button.
  const {
    inputProps: confirmProps,
    btnProps: confirmButton,
    matches,
  } = useViraPassword({ matchWith: password });
 
  return (
    <>
      <label htmlFor={inputProps.id}>New password</label>
      <div>
        <input {...inputProps} />
        <button {...btnProps} />
      </div>
 
      <label htmlFor={confirmProps.id}>Confirm password</label>
      <div>
        <input {...confirmProps} />
        <button {...confirmButton} />
      </div>
 
      <p aria-live="polite">
        {matches === null && "Repeat the password."}
        {matches === true && "Passwords match."}
        {matches === false && "Passwords don't match."}
      </p>
    </>
  );
}

Details

  • matches is null while the confirm field is empty.
  • Each field has its own show/hide button.
  • Both fields default to autoComplete="new-password".

For the hook API see useViraPassword(), for styling and icons see customization.

PreviousBasicNextCustom icons

On this page

  • Preview
  • Details
Something wrong? Fix it