Skip to content

Input

const Input: ForwardRefExoticComponent<InputProps & RefAttributes<InputHandle>>;

Text input with full keyboard editing, cursor navigation, and optional masking.

Supports both controlled (value + onChange) and uncontrolled (defaultValue) modes. Multiline editing is opt-in via the multiline prop.

Keyboard shortcuts (when focused):

KeyAction
← / →Move cursor
Home / EndStart / end of line
Ctrl+A / Ctrl+EStart / end of line
Ctrl+WDelete word backward
Ctrl+KDelete to end of line
Alt+← / Alt+→Move by word
Alt+BackspaceDelete word backward
Up / DownNavigate visual lines (multiline / wrapped)
const [name, setName] = useState("");
<Input
value={name}
onChange={setName}
placeholder="Your name"
style={{ border: "round", paddingX: 1 }}
focusedStyle={{ borderColor: "cyan" }}
/>
// Masked phone input
import { masks } from "@semos-labs/glyph";
<Input
value={phone}
onChange={setPhone}
onBeforeChange={masks.usPhone}
placeholder="(555) 555-5555"
/>

PropertyTypeDescription
autoFocus?booleanAutomatically focus this input when mounted.
defaultValue?stringInitial value for uncontrolled mode (ignored when value is provided).
focusedStyle?StyleStyle when focused (merged with style).
multiline?booleanEnable multiline editing (Enter inserts newlines, Up/Down navigate lines).
onBeforeChange?(newValue, oldValue) => string | false | voidCalled before a value change is applied. Useful for input masking/validation.
onChange?(value) => voidCallback fired whenever the text value changes.
onKeyPress?(key) => boolean | voidCalled on every key press. Return true to prevent default handling.
placeholder?stringText shown when the input is empty.
style?StyleBase style for the input container.
type?InputTypeInput type for validation: - “text” (default): accepts any character - “number”: only accepts digits, decimal point, and minus sign
value?stringControlled value. Pair with onChange to manage state externally.

type InputType = "text" | "number";

Input type for value validation.


Handle for Input — exposes current value

blur(): void;

Programmatically blur (unfocus) this element

void

FocusableHandle.blur


focus(): void;

Programmatically focus this element

void

FocusableHandle.focus


scrollIntoView(options?): void;

Scroll the nearest parent ScrollView to make this element visible. Behaves like the DOM Element.scrollIntoView() method. No-op if the element is not inside a ScrollView.

ParameterTypeDescription
options?ScrollIntoViewOptionsAlignment options (default: { block: "nearest" })

void

const inputRef = useRef<InputHandle>(null);
// Minimal scroll — just enough to make it visible
inputRef.current?.scrollIntoView();
// Center the element in the viewport
inputRef.current?.scrollIntoView({ block: "center" });

FocusableHandle.scrollIntoView

PropertyModifierTypeDescriptionInherited from
isFocusedreadonlybooleanWhether this element is currently focusedFocusableHandle.isFocused
valuereadonlystringCurrent text value-