Our Input for passwords: a show/hide toggle, a Caps Lock warning, and autocomplete for sign-in or a new password.
- Sign-in form
- Create an account
- Rotate an API login
- Confirm before deleting
Examples
Installation
npx knowns-ui@latest add password-fieldPaste this into your coding agent (Claude Code, Cursor, Codex). It checks your project, sets up the registry, runs the install and verifies it.
Install Password field from Knowns UI into this project. Work step by step, show me each change, and ask before you edit files outside this project.
Context: Knowns UI (https://ui.knowns.dev) is a shadcn registry. Items land in the project as source files. Docs: https://ui.knowns.dev/docs/password-field
1. Check the project first. Stop and tell me if any of these is missing:
- React 19 and Tailwind CSS v4.
- A components.json at the project root. If there is none, ask me before running `npx knowns-ui@latest init --no-key` (it runs shadcn init when needed, then adds the registries).
2. Run:
```bash
npx knowns-ui@latest add password-field
```
It writes these files:
- lib/knowns/run.ts
- lib/knowns/json.tsx
- lib/knowns/status.ts
- lib/knowns/tone.ts
- lib/knowns/types.ts
- lib/knowns/use-abortable.ts
- lib/knowns/utils.ts
- components/ui/knowns/kbd.tsx
- components/ui/knowns/field-class.ts
- components/ui/knowns/textarea.tsx
- components/ui/knowns/chat-composer/use-autosize.ts
- lib/knowns/motion.tsx
- lib/knowns/motion-utils.ts
- components/ui/knowns/use-floating.ts
- components/ui/knowns/tooltip.tsx
- components/ui/knowns/tooltip-utils.ts
- components/ui/knowns/input.tsx
- components/ui/knowns/password-field.tsx
and installs these npm packages: clsx@^2.1.1, tailwind-merge@^3.7.0.
3. While it runs:
- It also adds a few @keyframes (all named kn-*) to the global CSS file (globals.css or the file components.json points at). Let it: they only add animations.
- If it asks to overwrite files under lib/knowns/: these are shared by every Knowns UI item. List them, say whether I changed them (check git), and ask me before you answer.
- If it asks to overwrite any other file, show me the diff and ask me.
4. Verify:
- Every file in the list above exists.
- The project type-checks (for example `npx tsc --noEmit`) and the dev build has no new errors.
5. Use it: follow the examples and props on https://ui.knowns.dev/docs/password-field, and ask me if anything about my data is unclear.
If the Knowns UI MCP server is connected (https://ui.knowns.dev/docs/ai-and-mcp), use get_component({ name: "password-field" }) or search_docs for details.
Finish with a short summary: the files you added or changed, the packages you installed, and anything I still need to do.Props
- purpose
"current"|"new"- Default
"current" - Sets autocomplete to current-password (sign-in) or new-password (sign-up, change password).
- revealed / defaultRevealed / onRevealedChange
boolean- Default
false - Whether the value is shown. The eye button is a toggle with aria-pressed.
- capsLockWarning
boolean|ReactNode- Default
true - A "Caps Lock" chip in the field while it is on, also announced to screen readers. Pass text to change it, false to hide it.
- autoComplete
string- Overrides the token from purpose.
- size / invalid / disabled / ...
Input props- Everything else goes to Input. Inside a Field, label, hint, error and required are wired for you.
| Prop | Type | Default | Description |
|---|---|---|---|
| purpose | "current" | "new" | "current" | Sets autocomplete to current-password (sign-in) or new-password (sign-up, change password). |
| revealed / defaultRevealed / onRevealedChange | boolean | false | Whether the value is shown. The eye button is a toggle with aria-pressed. |
| capsLockWarning | boolean | ReactNode | true | A "Caps Lock" chip in the field while it is on, also announced to screen readers. Pass text to change it, false to hide it. |
| autoComplete | string | - | Overrides the token from purpose. |
| size / invalid / disabled / ... | Input props | - | Everything else goes to Input. Inside a Field, label, hint, error and required are wired for you. |
Caps Lock is read from key events, so the chip shows after the first key press and clears on blur. Some mobile keyboards don't report it; the chip just stays hidden there. Spell check, auto-capitalise and auto-correct are off.
What it handles
- 01Wraps Input with type password and an eye button that shows or hides the value, exposed as aria-pressed.
- 02Sets the autocomplete token from purpose: current-password for sign-in and new-password for sign-up, so password managers fill the right thing.
- 03Shows a Caps Lock chip while the key is on, read from getModifierState on key down and key up, and clears it on blur.
- 04Announces the Caps Lock state through a status region that is always in the DOM, and adds its id to aria-describedby while it shows.
- 05Takes revealed, defaultRevealed and onRevealedChange, so the show state can be controlled from outside.
- 06Turns off autocapitalize, autocorrect and spellcheck, and accepts every Input prop such as size, invalid and trailing.
States
- First render
- Nothing. The field paints hidden unless defaultRevealed is set
- none
- Caps Lock on
- The Caps Lock chip pops in inside the field
- 120ms, ease out
- Caps Lock off or blur
- The chip is removed
- none, at once
- Reveal toggle
- The value switches between dots and text
- none, at once
- Reduced motion
- The chip appears without the pop
- 0ms
| State | What moves | Timing |
|---|---|---|
| First render | Nothing. The field paints hidden unless defaultRevealed is set | none |
| Caps Lock on | The Caps Lock chip pops in inside the field | 120ms, ease out |
| Caps Lock off or blur | The chip is removed | none, at once |
| Reveal toggle | The value switches between dots and text | none, at once |
| Reduced motion | The chip appears without the pop | 0ms |
Works with
When to use
Using with AI
Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:
- Add the Knowns UI Password Field to my app and wire it to my own data.
- I need sign-in, sign-up and change-password fields: show/hide, a Caps Lock warning and the right autocomplete. Set that up with the Knowns UI Password Field.
- Which Password Field props do I need for a minimal setup? Show me a short example.
With the server connected, your assistant calls get_component({ name: "password-field" }) and search_docs({ query: "password field" }).