Text fields with one look: a hairline at rest, a soft halo on focus, red when something is wrong. Sizes, prefix and suffix, shortcuts, password reveal, groups, and Field for label, hint and error.
Used for
- API key field
- Search box
- Model name
- Webhook URL
- Password entry
Examples
Installation
npx knowns-ui@latest add inputFor Claude Code, Cursor or Codex: installs it and wires the props to your own data.
Paste this into your coding agent (Claude Code, Cursor, Codex). It checks your project, sets up the registry, runs the install and verifies it.
Install prompt
Install Input 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/input
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 input
```
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
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/input, 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: "input" }) 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
- size
"sm"|"md"|"lg"- Default
"md" - 28, 32 or 36px high; taller on touch screens. Matches Button sizes.
- icon
ReactNode- Icon on the left.
- prefix / suffix
ReactNode- Muted text inside the field, e.g. “https://” or “USD”. Clicking it focuses the input.
- shortcut
string- Keyboard hint on the right, e.g. “⌘K”. Visual only: wire the key yourself.
- trailing
ReactNode- Anything else on the right, such as a small button.
- type="password"
- Adds a show / hide button (aria-pressed).
- invalid
boolean- Default
false - Red ring and aria-invalid.
- className
string- On the outer frame; ref and other props go to the input.
| Prop | Type | Default | Description |
|---|---|---|---|
| size | "sm" | "md" | "lg" | "md" | 28, 32 or 36px high; taller on touch screens. Matches Button sizes. |
| icon | ReactNode | - | Icon on the left. |
| prefix / suffix | ReactNode | - | Muted text inside the field, e.g. “https://” or “USD”. Clicking it focuses the input. |
| shortcut | string | - | Keyboard hint on the right, e.g. “⌘K”. Visual only: wire the key yourself. |
| trailing | ReactNode | - | Anything else on the right, such as a small button. |
| type="password" | - | Adds a show / hide button (aria-pressed). | |
| invalid | boolean | false | Red ring and aria-invalid. |
| className | string | - | On the outer frame; ref and other props go to the input. |
- InputGroup
div props- Joins an Input with Buttons or Selects: square inner corners, one shared hairline. Give addons a fixed width (wrap a Select in a sized span).
- Field required / optional
boolean / boolean|ReactNode- An asterisk and aria-required on the control, or “Optional” next to the label.
- Field tooltip
ReactNode- Help behind an info button next to the label.
- Field hint / error
ReactNode- Under the control; also set aria-describedby (and aria-invalid for an error) on it.
- Textarea maxLength
number- Shows “120 / 500” under the field; red at the limit.
- Textarea autoGrow / maxRows
boolean / number- Default
false / 8 - Grows with the text up to maxRows, then scrolls.
| Prop | Type | Default | Description |
|---|---|---|---|
| InputGroup | div props | - | Joins an Input with Buttons or Selects: square inner corners, one shared hairline. Give addons a fixed width (wrap a Select in a sized span). |
| Field required / optional | boolean / boolean | ReactNode | - | An asterisk and aria-required on the control, or “Optional” next to the label. |
| Field tooltip | ReactNode | - | Help behind an info button next to the label. |
| Field hint / error | ReactNode | - | Under the control; also set aria-describedby (and aria-invalid for an error) on it. |
| Textarea maxLength | number | - | Shows “120 / 500” under the field; red at the limit. |
| Textarea autoGrow / maxRows | boolean / number | false / 8 | Grows with the text up to maxRows, then scrolls. |
What it handles
- 01Wraps a native input in a field frame with an icon, a prefix, a suffix, a Kbd shortcut hint and a trailing slot, in sm, md and lg sizes.
- 02Puts the caret in the input when you click the prefix, suffix or padding, but leaves buttons and links inside the frame clickable.
- 03Shows a Show password eye button for type password, with aria-pressed, controlled through revealed and onRevealedChange or left to manage itself.
- 04Marks the field with aria-invalid through the invalid prop and draws a red ring around the whole frame.
- 05Joins an Input with Buttons or a Select through InputGroup, squaring the inner corners so the hairlines meet.
- 06Ships Field, which wires a label, hint, error, required asterisk, Optional text and an info tooltip to the single control inside through ids and aria-describedby.
States
- First render
- Nothing. The field paints as it is
- none
- Focus
- The hairline becomes a ring colour with a soft halo around the frame
- 180ms, ease out
- Invalid
- The ring turns red
- 180ms, ease out
- Reveal password
- The eye icon swaps between open and struck through and the text switches type at once
- none, at once
- Eye hover
- The eye button gains a muted background
- 120ms, ease out
- Disabled
- The frame dims and the cursor changes
- none, at once
| State | What moves | Timing |
|---|---|---|
| First render | Nothing. The field paints as it is | none |
| Focus | The hairline becomes a ring colour with a soft halo around the frame | 180ms, ease out |
| Invalid | The ring turns red | 180ms, ease out |
| Reveal password | The eye icon swaps between open and struck through and the text switches type at once | none, at once |
| Eye hover | The eye button gains a muted background | 120ms, ease out |
| Disabled | The frame dims and the cursor changes | none, at once |
Works with
- TextareaInstalled with it. The multi-line field shares the same look and the same invalid ring.
- KbdInstalled with it. The shortcut prop renders a Kbd on the right of the field.
- TooltipInstalled with it. Field's tooltip prop puts help text behind an info icon.
- SelectPairs with it inside an InputGroup for a unit or currency next to a number.
When to use
When to use
- Single-line text, passwords and multi-line text with a label, hint and error.
When not to use
- Writing a prompt for an agent: use Chat Composer.
- Choosing from a known list: use Combobox.
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 Input to my app and wire it to my own data.
- I need single-line text, passwords and multi-line text with a label, hint and error. Set that up with the Knowns UI Input.
- Which Input props do I need for a minimal setup? Show me a short example.
With the server connected, your assistant calls get_component({ name: "input" }) and search_docs({ query: "input" }).