npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-password-field.json --yesPassword field
ProA field for a password with a button that shows or hides the typed words, for sign-in, sign-up and reset forms, for React and Tailwind CSS. Part of Goop Pro.
What an agent sees
- PasswordStrengthHow strong a new password is (
score, 0 to 4, fromscorePasswordor your own code) - PasswordRulesThe rules a new password must meet, as a checklist
- scorePasswordScores a new password for PasswordStrength and tests it against the rules PasswordRules lists, in one call
import { useState } from 'react';
import { Field } from '@/components/ui/goop/field';
import {
PasswordField,
PasswordRules,
PasswordStrength,
scorePassword,
} from '@/components/ui/goop/password-field';
function NewPassword() {
const [password, setPassword] = useState('');
const { score, rules } = scorePassword(password);
return (
<Field label="Password" orientation="vertical" className="w-full">
<PasswordField
purpose="new"
name="password"
value={password}
onChange={(event) => setPassword(event.currentTarget.value)}
>
<PasswordStrength score={score} />
<PasswordRules rules={rules} />
</PasswordField>
</Field>
);
}Type a password and watch the strength and the rules follow each key; show and hide it with the eye (the line under the form says which); turn Caps Lock on to see the warning. Create account is refused until the password reads Fair or better, then the account is made. No account is made and nothing is sent; the check of leaked passwords a server owes is not there.
When to use
- A field for a password with a button that shows or hides the typed words, for sign-in, sign-up and reset forms.
- Use PasswordField for every password; never a TextInput with
type="password". Put PasswordStrength and PasswordRules under it (as its children) only where a person is choosing a new password, fed byscorePassword(password)(or your own scoring), and never add a field to repeat it: the button lets a person check what they typed. - Also called: password input.
Installation
Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Password field on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing. As a Pro part, its command comes from Goop's server once you sign in, with a one-time link that lasts ten minutes.
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-password-field.json --yesAdd the Goop Password field to this project. The install steps are at https://goop.so/docs/install.mdUsage
import { useState } from 'react';
import { Field } from '@/components/ui/goop/field';
import {
PasswordField,
PasswordRules,
PasswordStrength,
scorePassword,
} from '@/components/ui/goop/password-field';
function NewPassword() {
const [password, setPassword] = useState('');
const { score, rules } = scorePassword(password);
return (
<Field label="Password" orientation="vertical" className="w-full">
<PasswordField
purpose="new"
name="password"
value={password}
onChange={(event) => setPassword(event.currentTarget.value)}
>
<PasswordStrength score={score} />
<PasswordRules rules={rules} />
</PasswordField>
</Field>
);
}- Fits: account (its recipe).
- Also known as: PasswordInput, Input type="password", ShowPassword, PasswordToggle.
- height, width, padding, gap, background, text: add no class for these.
API reference
- Each option with its sentence: password-field--options.md
- State: visible (visible / defaultVisible / onVisibleChange)
- Types: PasswordRule = { label: ReactNode; met: boolean }
| Part | What it is |
|---|---|
| PasswordStrength | How strong a new password is (score, 0 to 4, from scorePassword or your own code); its props: password-field--password-strength.md |
| PasswordRules | The rules a new password must meet, as a checklist; rules: readonly PasswordRule[] — The rules, in the order they are read; metLabel?: string = 'met' — The hidden word read after a rule that is met; it never shows; unmetLabel?: string = 'not met' — The hidden word read after a rule that is not met yet; it never shows |
| scorePassword | Scores a new password for PasswordStrength and tests it against the rules PasswordRules lists, in one call |
- data-slot values (to select a part by): password-field, password-field-addon, password-field-content, password-field-frame, password-field-status, password-field-status-icon, password-rule, password-rule-icon, password-rules, password-strength, password-strength-description, password-strength-header, password-strength-icon, password-strength-label, password-strength-value
PasswordField: every option
import { PasswordField } from '@/components/ui/goop/password-field';Options
- purpose?: 'current' | 'new' = 'current' — What the password is for:
currenta sign-in or a confirm step,newa sign-up or a change — it setsautoCompletetocurrent-passwordornew-password(anautoCompleteof your own wins). - visible?: boolean — Whether the typed words show, controlled.
- defaultVisible?: boolean = false — Whether the typed words show at first, uncontrolled (hidden if left out).
- onVisibleChange?: (visible: boolean) => void — Called with whether the words show, each time the button is pressed and when the form is sent (
false). - showLabel?: string = 'Show password' — The button's one name, read with its pressed state; a second field on the page names its own ("Show repeated password").
- capsLockNotice?: ReactNode | false = 'Caps Lock is on' — The words shown while Caps Lock is on and the field has the focus;
falseshows none. - children?: ReactNode — What stands under the field, in its column: a
PasswordStrength, then aPasswordRules. - Also takes: value?: string; defaultValue?: string; onChange?: (event: ChangeEvent<HTMLInputElement>) => void; name?: string; required?: boolean; disabled?: boolean; form?: string
- State: visible (visible / defaultVisible / onVisibleChange)
PasswordStrength
How strong a new password is (score, 0 to 4, from scorePassword or your own code).
import { PasswordStrength } from '@/components/ui/goop/password-field';Options
- score: 0 | 1 | 2 | 3 | 4 — The password's strength, 0 (too short) to 4 (strong):
scorePassword'sscore, or your own code's. - words?: readonly [string, string, string, string, string] — The word for each score, weakest first (default Too short, Weak, Fair, Good, Strong).
- label?: ReactNode = 'Strength' — What the bar measures, over its start.
- overLabel?: string = 'Too weak' — The words read with the bar under Fair (Too short and Weak), where it warns (default "Too weak").
- aria-label?: string — The bar's name where no
labelis drawn.
Keyboard
| Key | What it does |
|---|---|
| Tab | Move from the field to its show-password button, then on to the next control |
| Enter Space | On the button: show the typed words, or hide them again |
Accessibility
- The part itself answers the keys above.
- focus: the browser's own (:focus): write nothing
Its states are drawn from attributes and props, so assistive technology and your agent read the same thing:
| State | Drawn by |
|---|---|
| pressed | the attribute aria-pressed |
| disabled | the prop disabled |
Notes for AI
Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.