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

Show / hide

Toggle with focus handling, hiding on submit and a Caps Lock hint.

← All examples·show-hide

Preview

// components/password-field.tsx
"use client";
 
import { useViraPassword } from "@virastack/password";
 
export function PasswordField() {
  const { inputProps, btnProps, capsLock } = useViraPassword();
 
  return (
    <>
      <label htmlFor={inputProps.id}>Password</label>
      <div>
        <input {...inputProps} placeholder="Your password" />
        <button {...btnProps} />
      </div>
      {capsLock && <p>Caps Lock is on</p>}
    </>
  );
}

Details

  • A mouse click returns focus to the input; Enter or Space keeps it on the button.
  • The password is hidden again when the form is submitted.
  • capsLock is true while Caps Lock is on and the input has focus.

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

PreviousServer ActionNextSign-up with Mask

On this page

  • Preview
  • Details
Something wrong? Fix it