Input
An unstyled single-line text input wrapping a native text editor with controlled/uncontrolled state, IME events, and reset support.
Base Input (base-input-root) renders a single native <input type="text"> on the Web, providing controlled/uncontrolled value handling, IME composition events, focus methods, and accessibility props without built-in styling.
Preview
Section titled “Preview”Installation
Section titled “Installation”Available starting in 0.3.0-rc.1 and later releases. Import the default Root, inputRoot, or asInputRoot from @proto.ui/prototypes-base/input. For a styled version, see Shadcn Input.
Value ownership and events
Section titled “Value ownership and events”- Uncontrolled: initialize with
defaultValue; later updates to unrelated props preserve user edits. - Controlled: pass
valueso edits emitvalueChangeproposals and only commit when your application passes the newvalueback. Ownership mode is fixed at instance creation. - Event payloads:
valueChangecarries{ value, composing, data, inputType },changecarries{ value }, andcompositionStart/compositionUpdate/compositionEndcarry{ value, data }.
Resetting the editor (resetValue)
Section titled “Resetting the editor (resetValue)”Mounted instances expose resetValue(value?: string): boolean to reset the active editing and IME composition session without synthesizing valueChange, change, or compositionEnd:
- Uncontrolled with a string: resets the text to the supplied string (with CR/LF line breaks stripped) and returns
true. - Uncontrolled with no argument (or
undefined): resets to the latestdefaultValue(normalized to a single line) and returnstrue. - Controlled: clears any active IME composition session while retaining the controlled
value, returningfalse. CallingresetValueon an unmounted/detached view or with a non-string value also returnsfalse.
Use Set latest default, Reset to default, Reset to sample, and Try controlled reset in the preview to inspect these behaviors.
Focus and exposed state
Section titled “Focus and exposed state”Exposed APIs include focusSelf(), blurSelf(), and resetValue(value?), plus the value, disabled, readOnly, focused, focusVisible, and composing states. Use inputMode and enterKeyHint to provide virtual-keyboard hints.
Root Props
Section titled “Root Props”Passing value selects controlled mode.
| Prop | Type | Default |
|---|---|---|
value | string | undefined |
defaultValue | string | '' |
disabled | boolean | false |
readOnly | boolean | false |
placeholder | string | '' |
required | boolean | false |
name | string | '' |
autoComplete | string | '' |
minLength | number | -1 |
maxLength | number | -1 |
inputMode | 'none' 'text' 'tel' 'url' 'email' 'numeric' 'decimal' 'search' | undefined |
enterKeyHint | 'enter' 'done' 'go' 'next' 'previous' 'search' 'send' | undefined |
ariaLabel | string | '' |
labelledBy | string | '' |
describedBy | string | '' |