---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Password field

A 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.

Pro. Its export: `PasswordField`.

## Try it

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 by `scorePassword(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.

```sh
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-password-field.json --yes
```

```text
Add the Goop Password field to this project. The install steps are at https://goop.so/docs/install.md
```

## Usage

```tsx
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

### Parts

- `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

```tsx
import { PasswordField } from '@/components/ui/goop/password-field';
```

### Options

- purpose?: 'current' | 'new' = 'current' — What the password is for: `current` a sign-in or a confirm step, `new` a sign-up or a change — it sets `autoComplete` to `current-password` or `new-password` (an `autoComplete` of 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; `false` shows none.
- children?: ReactNode — What stands under the field, in its column: a `PasswordStrength`, then a `PasswordRules`.
- 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).

```tsx
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`'s `score`, 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 `label` is drawn.

## Keyboard

- 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
- 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.

## Related

- [Field](/themes/meadow/components/field): A form row that ties one control to its label and its description, as a settings row or a stacked form field.
- [Number input](/themes/meadow/components/number-input): A field for a number, an amount or a quantity, typed in the reader's language or stepped with the arrow keys.
- [Input group](/themes/meadow/components/input-group): A text field with an action joined to it inside its fill.
- [OTP input](/themes/meadow/components/otp-input): A row of single-character cells for a one-time code, for a two-step sign-in or confirming an email or a phone.
