ViraStack
  • About
  • Support
HomeGet StartedExamples

Getting started

  • Introduction
  • llms.txt
  • llms-full.txt

Usage

  • useViraPassword()
  • Accessibility
  • Customization
  • Helpers
  • Types
  • UI libraries

Helpers

Core helpers, icons, and mergeProps you can use outside the hook.

Core helpers

Framework-agnostic functions: usable without React state:

FunctionDescription
getInputType(isVisible)"password" | "text"
getButtonAriaAttributes(isVisible, inputId, label?)aria-* and type="button" for the button
getInputAriaAttributes(isInvalid?, describedBy?)Optional aria-invalid / aria-describedby
import {
  getInputType,
  getButtonAriaAttributes,
  getInputAriaAttributes,
  mergeProps,
  EyeIcon,
  EyeOffIcon,
} from "@virastack/password"
 
getInputType(false) // "password"
getInputType(true)  // "text"
 
getButtonAriaAttributes(true, "pwd-1")
// {
//   "aria-label": "Toggle password visibility",
//   "aria-pressed": true,
//   "aria-controls": "pwd-1",
//   type: "button",
// }
 
getInputAriaAttributes(true, "pwd-error")
// { "aria-invalid": true, "aria-describedby": "pwd-error" }

Icons

Default EyeIcon / EyeOffIcon (16×16 SVG, currentColor). The hook renders them; you can import them in your own UI too.

mergeProps

The merger used by the hook is exported: chains on* handlers, joins className strings, and for other keys the later value wins. Handy for manual merges in controlled components.

PreviousCustomizationNextTypes

On this page

  • Core helpers
  • Icons
  • mergeProps
Something wrong? Fix it