# PasswordInput

A password input with a trailing button that shows or hides what was typed. The ref, `Field` wiring and input attributes such as `autoComplete` go to the input.

## Use for

- a password field
- a password with a show or hide toggle

## Practices

- Do: Pass localized `showPasswordLabel` and `hidePasswordLabel`. They name the toggle.
- Do: Set `autoComplete` to `current-password` or `new-password`, so password managers fill the right value.
- Don't: Use `Input` with `type="password"` and your own toggle.

## API reference

### PasswordInput

An `InputGroup` around the input and toggle. Carries `data-visible` while the password shows; the toggle is `cl-password-input-toggle`.

Slot: `cl-password-input`

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | `sm`, `md` or `lg`. |
| `showPasswordLabel` | `string` |  | The toggle name while the password is hidden. |
| `hidePasswordLabel` | `string` |  | The toggle name while the password shows. |

## Examples

### A sign-in password

```tsx
<Field.Root>
  <Field.Label>Password</Field.Label>
  <PasswordInput
    autoComplete='current-password'
    showPasswordLabel='Show password'
    hidePasswordLabel='Hide password'
  />
</Field.Root>
```

## Related

- [Input](/docs/components/input.md)
- [InputGroup](/docs/components/input-group.md)
- [Field](/docs/components/field.md)
