Skip to content

Input

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.

On this page
Used for
  • API key field
  • Search box
  • Model name
  • Webhook URL
  • Password entry

Examples

Installation

npx knowns-ui@latest add input
For Claude Code, Cursor or Codex: installs it and wires the props to your own data.

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
Defaultfalse
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
Defaultfalse / 8
Grows with the text up to maxRows, then scrolls.

What it handles

  1. 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.
  2. 02Puts the caret in the input when you click the prefix, suffix or padding, but leaves buttons and links inside the frame clickable.
  3. 03Shows a Show password eye button for type password, with aria-pressed, controlled through revealed and onRevealedChange or left to manage itself.
  4. 04Marks the field with aria-invalid through the invalid prop and draws a red ring around the whole frame.
  5. 05Joins an Input with Buttons or a Select through InputGroup, squaring the inner corners so the hairlines meet.
  6. 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

Works with

When to use

When to use

  • Single-line text, passwords and multi-line text with a label, hint and error.

When not 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 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" }).

Need help?

Stuck on Input, or found something off? We read every message.