Skip to content

input class

A control that displays some text that can potentially be edited.

Methods

__init__()

__init__(
    value=None,
    password=False,
    label=None,
    multiline=False,
    lines_shown=5,
    type="text",
    action_on_blur=False,
    change_delay=None, # App config
    on_action=None,
    action_keys="Enter",
    width=None,
    on_change=None,
    propagate=None, # App config
    active=True,
    id=None,
    properties=None,
    class_name=None,
    hover_text=None,
) -> None

Create a new input element.

Parameters:

Name Type Description Default

value

Any
dynamic

The value represented by this control.

None

password

bool

If True, the text is obscured, and all characters are displayed as asterisks ('*').
This can be useful for sensitive information such as passwords.

False

label

str

The label associated with the input field.
This provides context to the user and improves accessibility.

None

multiline

bool

If True, the input is rendered as a multi-line text area
The default behavior is a single-line input.

False

lines_shown

int

The number of lines displayed in the input control when multiline is True.

5

type

str

The type of input element, as per HTML input types.
This property enforces specific input formats where applicable. Supported values include "text", "tel", "email", "url", etc.

text

action_on_blur

bool

If True, the on_action callback is triggered when the input control looses keyboard focus (e.g., when the user presses the Tab key). When this happens, the key name for the event (set in the args property of the payload parameter to the callback function) is set to "Tab".

False

change_delay

int

The minimum interval (in milliseconds) between two consecutive calls to the on_change callback.
The default value is defined at the application configuration level by the change_delay configuration option.
if None, the delay is set to 300 ms.
If set to -1, the callback is triggered only when the user presses the Enter key.

App config

on_action

Union[str, Callable]

A function or the name of a function that is triggered when a specific key is pressed.
The callback function is invoked with the following parameters:

  • state (State): the state instance.
  • id (str): the identifier of the control if it has one.
  • payload (dict): the callback details
    This dictionary has the following keys:
    • action: the name of the action that triggered this callback.
    • args (list):
      • The key name pressed.
      • The variable name.
      • The current value of the variable.
None

action_keys

str

A semicolon-separated list of keys that can trigger the on_action callback.
Authorized values are Enter, Escape, and function keys F1 to F12.

Enter

width

Union[str, int]

The width of the element, in CSS units.

None

on_change

Union[str, Callable]

A function or the name of a function that is triggered when the value changes.
The callback function receives the following parameters:

  • state (State): the state instance.
  • var_name (str): the bound variable name.
  • value (Any): the updated value.
None

propagate

bool

Determines whether the control's value is automatically reflected in the bound application variable.
The default value is defined at the application configuration level by the propagate configuration option.
If True, any change to the control's value is immediately reflected in the variable.

App config

active

bool
dynamic

Indicates if this element is active.
If False, the element is disabled, and user interaction is not allowed.

True

id

str

The identifier assigned to the rendered HTML component.
This can be used in callbacks or to target the element for styling.

None

properties

dict[str, Any]

A dictionary of additional properties that can be set to the element.

None

class_name

str
dynamic

A space-separated list of CSS class names to be applied to the generated HTML element.
These classes are added to the default taipy-input class.

None

hover_text

str
dynamic

The text that is displayed when the user hovers over the element.

None