Reflex Logo
Docs Logo
Library

/

Forms

/

Input

The input component is an input field that users can type into.

The on_blur event handler is called when focus has left the input for example, it’s called when the user clicks outside of a focused text input.

Hello World!

The on_change event handler is called when the value of input has changed.

Hello World!

Behind the scenes, the input component is implemented as a debounced input to avoid sending individual state updates per character to the backend while the user is still typing. This allows a state variable to directly control the value prop from the backend without the user experiencing input lag.

The type prop controls how the input is rendered (e.g. plain text, password, file picker).

It accepts the same values as the native HTML <input type> attribute, such as:

  • "text" (default)
  • "password"
  • "email"
  • "number"
  • "file"
  • "checkbox"
  • "radio"
  • "date"
  • "time"
  • "url"
  • "color"

and several others. See the MDN reference for the full list.

The name prop is needed to submit with its owning form as part of a name/value pair.

When the required prop is True, it indicates that the user must input text before the owning form can be submitted.

The type is set here to password. The element is presented as a one-line plain text editor control in which the text is obscured so that it cannot be read. The type prop can take any value of email, file, password, text and several others. Learn more here.

Example Form

Results:

{}

To learn more about how to use forms in the Form docs.

Set the value of the specified reference element, without needing to link it up to a State var. This is an alternate way to modify the value of the input.

API Reference

rx.input

Captures user input with an optional slot for buttons and icons.

Test
PropType | ValuesDefaultInteractive
access_key
str
-
auto_capitalize
"off" | "none" | ...
-
content_editable
Union["inherit" | "plaintext-only", bool]
-
context_menu
str
-
dir
str
-
draggable
bool
-
enter_key_hint
"enter" | "done" | ...
-
hidden
bool
-
input_mode
"none" | "text" | ...
-
item_prop
str
-
lang
str
-
role
"alert" | "alertdialog" | ...
-
slot
str
-
spell_check
bool
-
tab_index
int
-
title
str
-
accept
str
-
alt
str
-
auto_complete
bool
-
auto_focus
bool
-
capture
Union["user" | "environment", bool]
-
checked
bool
-
default_checked
bool
-
default_value
str
-
disabled
bool
-
form
str
-
form_action
str
-
form_enc_type
str
-
form_method
str
-
form_no_validate
bool
-
form_target
str
-
list
str
-
max
Union[str, int, float]
-
max_length
int
-
min_length
int
-
min
Union[str, int, float]
-
multiple
bool
-
name
str
-
pattern
str
-
placeholder
str
-
read_only
bool
-
required
bool
-
size
"1" | "2" | ...
-
src
str
-
step
Union[str, int, float]
-
type
str
-
value
Union[str, int, float]
-
variant
"classic" | "surface" | ...
-
color_scheme
"tomato" | "red" | ...
-
radius
"none" | "small" | ...
-

Event Triggers

See the full list of default event triggers
TriggerDescription
on_key_downFired when a key is pressed down.
on_key_upFired when a key is released.
on_changeFired when the value of the textarea changes.

rx.input.slot

Contains icons or buttons associated with an Input.

PropType | ValuesDefaultInteractive
color_scheme
"tomato" | "red" | ...
-
side
"left" | "right"
-

Built with Reflex