# Password Strength (Notchset): prompt.md (v1.0.0)

- id: `password-strength` · version 1.0.0 · component · pro (Pro)
- category: Inputs
- build: Base UI (one set of files; its dependencies follow the build)
- install (this build): `npx shadcn@latest add @beautiful-ui-pro/password-strength`
- npm dependencies: none
- registry dependencies: utils, https://beautiful-ui.dev/r/notchset-foundation.json
- docs: https://beautiful-ui.dev/components/password-strength
- The install command carries everything this item needs (files, CSS, tokens, npm and registry dependencies). Prefer it to copying source by hand.

A new-password field with a 16-node meter that lights one node per 5 bits, the level and time to crack on one line, a sentence of advice, and a Generate key that types a passphrase in.

## Build it
- Stack: React 19 (`ref` is a plain prop), TypeScript, Tailwind CSS v4 utilities, a shadcn-initialised project with the `@/*` alias.
- Packages: none beyond React.
- Files: `components/ui/notchset/password-strength.tsx`; shared code: `lib/beautiful-ui/notchset/password.tsx`, `lib/beautiful-ui/notchset/instrument.tsx`, `lib/beautiful-ui/notchset/root.ts`.
- Registry dependencies, installed with it automatically: shadcn `utils` (cn), `notchset-foundation`.
- Builds: one set of files for both, but its dependencies come in Base UI and Radix builds. Install the one that matches the project (see Install): a free item's bare URL installs the Base UI build of it and its dependencies.
- Exports to keep: `PasswordMeter`, `PasswordStrength`, `scorePassword`, and every exported type.
- CSS: the install adds the notchset foundation (tokens, keyframes, motion levels) to your global stylesheet once. Nothing to import by hand.
- Re-running `add` (or `--overwrite`) re-applies those rules: put overrides in your own CSS, never in the installed rules.
- Tokens: retheme with the `--notchset-*` custom properties (`--notchset-check`, `--notchset-control-edge`, `--notchset-draw-from`, `--notchset-ease-bloom`, `--notchset-ease-travel`, `--notchset-fade`, `--notchset-focus-color`, `--notchset-focus-inset`, `--notchset-life-from`, `--notchset-life-ms`, `--notchset-node-blink`, `--notchset-node-bloom`, `--notchset-node-delay`, `--notchset-plate-color`, `--notchset-rise-from`, `--notchset-rule`, `--notchset-scroll`, `--notchset-signal`, `--notchset-sweep-to`). Never add Tailwind colour classes inside the component.

```tsx
import { PasswordStrength } from "@/components/ui/notchset/password-strength";
```

## Parts

| Part | data-slot | What it is for |
|---|---|---|
| `PasswordStrength` | `password-strength-root` | Field, meter and advice. |
| `PasswordMeter` | `password-strength` | The meter alone. |

Style a part with `[data-slot="<slot>"]` selectors or its `className`; keep the attributes when editing.

## Sound
- Keep every `data-slot` and `data-sound` attribute: the sound layer reads them.
- Installing this item adds no audio. Nothing plays until the app mounts `SoundProvider` once (install: `npx shadcn@latest add https://beautiful-ui.dev/r/notchset-sound.json`, import from `@/components/ui/notchset/sound-provider`); `useSound()` gives `muted` and `setMuted` for a mute control. Without a provider the audio engine never loads.

## Match the original
- Read `components/ui/notchset/password-strength.tsx` as the reference implementation before changing or recreating anything, and match it: sizes, colours per theme, motion timings, copy and behaviour.
- If you deviate (a prop you can't honour, a style you changed, a dependency you swapped), say so in your reply, part by part.
- Keep the accessibility contract, the keyboard map and the motion levels listed below.

## Use it when
- password strength, password meter, new password, entropy, generate password, Notchset
- Choosing or changing a password, especially for service accounts

### Not when
- Signing in: use Password Field

## Mistakes
- The built-in scorer is a guide; use zxcvbn-ts for real checks

## Usage

```tsx
"use client";

import * as React from "react";
import { PasswordStrength } from "@/components/ui/notchset/password-strength";

const WORDS = ["copper", "orbit", "lantern", "meadow", "signal", "harbor", "violet", "summit"];
const passphrase = () => Array.from({ length: 4 }, () => WORDS[Math.floor(Math.random() * WORDS.length)]).join("-");

export function NewPassword() {
  const [password, setPassword] = React.useState("");
  return <PasswordStrength value={password} onValueChange={setPassword} generate={passphrase} />;
}
```

## Props

| Prop | Type | Default | What it does |
|---|---|---|---|
| `value / onValueChange` | `string / fn` |  | Controlled. |
| `generate` | `() => string` |  | Typed in one character every 34ms, with the field shown. |
| `score` | `(v) => { bits, common }` |  | Your scorer (zxcvbn-ts in production); the visual stays. |
| `advice` | `(level, strength) => string` |  | The sentence under the meter. |

Full docs: https://beautiful-ui.dev/components/password-strength

## Customising
- Colours: the component reads your shadcn tokens (`--background`, `--foreground`, `--border` …), refined by the `--notchset-*` tokens. The signal colour is `--notchset-signal` (it falls back to `--destructive`). Set tokens on `:root`, or on any container to retheme one area.
- Dark mode follows the `.dark` class on an ancestor (the shadcn and next-themes convention).
- Update later by re-running the install with `--overwrite` (review the diff if you edited it). Changelog: https://beautiful-ui.dev/r/changelog.json

## Keyboard

| Keys | Action |
|---|---|
| Tab | Reach Generate and show/hide |

## Performance

- Scoring runs on change and is a few string tests; swap in zxcvbn-ts for real checks.
- Generate types with one timer that stops if you type over it.

## Responsive

- Fills its container; the meter scales with it and the level and crack time stay on one line.

## Motion inventory

| Interaction | What moves |
|---|---|
| Score | Lit nodes pop (280ms) 18ms apart by fours; a 2px run traces to the last (320ms) |
| Generate | Types the passphrase in, 34ms a character, with the scanner running |

## Accessibility contract (preserve when editing)
- The meter is role=meter with its level as valuetext
- The advice is polite live text that describes the input

## Install

```bash
npx shadcn@latest add @beautiful-ui-pro/password-strength
```

Pro item: needs the `@beautiful-ui-pro` registry in `components.json` and `BEAUTIFUL_UI_TOKEN` in `.env.local` (https://beautiful-ui.dev/account). Setup: https://beautiful-ui.dev/docs/pro. Your components.json `style` picks the build: radix-*, new-york and default get Radix, base-* gets Base UI.

## Credits
- Built on shadcn/ui (https://ui.shadcn.com)

The notchset foundation (the tokens listed above, keyframes and motion levels) installs once with the first component; its CSS is public at https://beautiful-ui.dev/r/notchset-foundation.json.
