Reflex Cloud - Fast, secure & scalable hosting. One command to deploy.

Input

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

Basic Example

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.

Submitting a form using input

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.

Setting a value without using a State var

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
size
"1" | "2" | ...
variant
"classic" | "surface" | ...
color_scheme
"tomato" | "red" | ...
radius
"none" | "small" | ...
auto_complete
bool
default_value
str
disabled
bool
max_length
int
min_length
int
name
str
placeholder
str
read_only
bool
required
bool
type
str
value
Union[str, int, float]
list
Union[str, int, bool]
accept
Union[str, int, bool]
alt
Union[str, int, bool]
auto_focus
Union[str, int, bool]
capture
Union[str, int, bool]
checked
Union[str, int, bool]
default_checked
bool
dirname
Union[str, int, bool]
form
Union[str, int, bool]
form_action
Union[str, int, bool]
form_enc_type
Union[str, int, bool]
form_method
Union[str, int, bool]
form_no_validate
Union[str, int, bool]
form_target
Union[str, int, bool]
max
Union[str, int, bool]
min
Union[str, int, bool]
multiple
Union[str, int, bool]
pattern
Union[str, int, bool]
src
Union[str, int, bool]
step
Union[str, int, bool]
use_map
Union[str, int, bool]

Event Triggers

See the full list of default event triggers
TriggerDescription
on_focus Fired when the textarea is focused.
on_blur Fired when the textarea is blurred.
on_change Fired when the value of the textarea changes.
on_key_down Fired when a key is pressed down.
on_key_up Fired when a key is released.

rx.input.slot

Contains icons or buttons associated with an Input.

PropType | ValuesDefaultInteractive
color_scheme
"tomato" | "red" | ...