Input-class: Input widget

InputR Documentation

Input widget

Description

A single-line text input. See input().

Super class

Widget -> Input

Public fields

paint_states

Cursor and selection changes only repaint.

focusable

Inputs can be focused.

placeholder

Text shown while the input is empty.

password

Show bullets instead of the characters?

max_length

Maximum number of characters, or NULL.

validate

NULL or ⁠function(value)⁠ returning NULL (valid) or an error message.

Active bindings

value

The text (reactive). Assigning moves the cursor to the end and sends "input.changed".

cursor_position

Cursor position in characters (0 = start).

selection

The selected text ("" if none).

valid

Does the value pass validate?

error

The validation message, or NULL.

Methods

Public methods

Inherited methods

Input$new()

Create an input.

Usage
Input$new(
  value = "",
  placeholder = "",
  id = NULL,
  classes = NULL,
  style = NULL,
  disabled = FALSE,
  password = FALSE,
  max_length = NULL,
  validate = NULL
)
Arguments
value

Initial text.

placeholder

Placeholder text.

id, classes, style, disabled

See Widget.

password

Mask the characters?

max_length

Maximum number of characters.

validate

Validation function.


Input$default_style()

The built-in style.

Usage
Input$default_style()

Input$pseudo_states()

Active states: focus, hover, disabled and invalid.

Usage
Input$pseudo_states()

Input$default_bindings()

Editing key bindings.

Usage
Input$default_bindings()

Input$on_key()

Printable keys replace the selection or are inserted at the cursor. Ctrl+C / Ctrl+X copy / cut when text is selected (otherwise Ctrl+C keeps its app meaning).

Usage
Input$on_key(event)
Arguments
event

A KeyEvent.


Input$on_mouse_down()

Clicking places the cursor; shift+click and dragging select.

Usage
Input$on_mouse_down(event)
Arguments
event

A MouseEvent.


Input$on_mouse_move()

Dragging with the left button extends the selection.

Usage
Input$on_mouse_move(event)
Arguments
event

A MouseEvent.


Input$on_paste()

Pasted text is inserted as one edit. An Input is a single line, so line breaks in the paste become spaces.

Usage
Input$on_paste(event)
Arguments
event

A PasteEvent.


Input$insert()

Insert text at the cursor (replacing the selection).

Usage
Input$insert(text)
Arguments
text

A string.


Input$clear()

Remove all text.

Usage
Input$clear()

Input$select_range()

Select a range of characters.

Usage
Input$select_range(start, end)
Arguments
start, end

Positions (0 = before the first character).


Input$copy()

Copy the selection to the app clipboard (and, when system = TRUE and supported, to the system clipboard via OSC 52).

Usage
Input$copy(system = TRUE)
Arguments
system

Also write to the system clipboard?


Input$action_cursor_left()

Move one character left.

Usage
Input$action_cursor_left()

Input$action_cursor_right()

Move one character right.

Usage
Input$action_cursor_right()

Input$action_cursor_home()

Move to the start.

Usage
Input$action_cursor_home()

Input$action_cursor_end()

Move to the end.

Usage
Input$action_cursor_end()

Input$action_word_left()

Move to the previous word.

Usage
Input$action_word_left()

Input$action_word_right()

Move to the next word.

Usage
Input$action_word_right()

Input$action_select_left()

Extend the selection left.

Usage
Input$action_select_left()

Input$action_select_right()

Extend the selection right.

Usage
Input$action_select_right()

Input$action_select_home()

Select to the start.

Usage
Input$action_select_home()

Input$action_select_end()

Select to the end.

Usage
Input$action_select_end()

Input$action_select_word_left()

Select to the previous word.

Usage
Input$action_select_word_left()

Input$action_select_word_right()

Select to the next word.

Usage
Input$action_select_word_right()

Input$action_select_all()

Select everything.

Usage
Input$action_select_all()

Input$action_delete_left()

Delete the selection or the character before the cursor.

Usage
Input$action_delete_left()

Input$action_delete_right()

Delete the selection or the character at the cursor.

Usage
Input$action_delete_right()

Input$action_delete_word_left()

Delete the word before the cursor.

Usage
Input$action_delete_word_left()

Input$action_delete_word_right()

Delete the word after the cursor.

Usage
Input$action_delete_word_right()

Input$action_delete_to_start()

Delete everything before the cursor.

Usage
Input$action_delete_to_start()

Input$action_delete_to_end()

Delete everything after the cursor.

Usage
Input$action_delete_to_end()

Input$action_paste()

Insert the app clipboard.

Usage
Input$action_paste()

Input$action_submit()

Send an "input.submitted" message (Enter).

Usage
Input$action_submit()

Input$content_width()

Natural content width.

Usage
Input$content_width()

Input$render_lines()

The visible part of the text, scrolled so the cursor is visible, with the cursor drawn in reverse video and the selection highlighted when focused.

Usage
Input$render_lines(width = NA_integer_)
Arguments
width

Content width.


Input$clone()

The objects of this class are cloneable with this method.

Usage
Input$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


termr documentation built on Oct. 21, 2026, 5:13 p.m.