Password input with show/hide toggle and a live strength checklist.
Set your access key from API keys as NEXTUI_TOKEN in .env.local and add the @nextui namespace below to components.json once. Then every item installs by name. Each install counts as a copy on a free account.
$pnpm dlx shadcn@latest add @nextui/password-input
1{2"registries": {3"@nextui": {4"url": "https://nextui.dev/r/{name}.json",5"headers": { "Authorization": "Bearer ${NEXTUI_TOKEN}" }6}7}8}
1"use client";23import { useState } from "react";4import { PasswordStrengthInput, type PasswordRule } from "@/components/nextui/password-input";56const rules: PasswordRule[] = [7{ label: "12+ characters", test: (v) => v.length >= 12 },8{ label: "A number", test: (v) => /\d/.test(v) },9{ label: "A symbol", test: (v) => /[^A-Za-z0-9]/.test(v) },10];1112export function SignupPassword() {13const [password, setPassword] = useState("");14const [strong, setStrong] = useState(false);1516return (17<PasswordStrengthInput18label="Choose a password"19name="password"20rules={rules}21value={password}22onChange={(value, score) => {23setPassword(value);24setStrong(score === rules.length);25}}26/>27);28}
| Prop | Type | Default | Description |
|---|---|---|---|
| label | ReactNode | "Password" | Text of the label above the field |
| placeholder | string | "Create a password" | Placeholder text |
| id | string | "password-03" | Field id, linked to the label |
| name | string | – | Field name for form submits |
| rules | PasswordRule[] | 8+ chars, number, uppercase, symbol | Requirements shown as meter segments and a checklist |
| value | string | – | Controlled value |
| defaultValue | string | "" | Starting value when uncontrolled |
| onChange | (value: string, score: number) => void | – | Called with the new value and how many rules it passes |
| className | string | – | Extra classes on the wrapper |
Sign in to see the code
Preview it freely. A free account copies code and prompts a few times a day.