Input
Overview¶
Input allows the user to type in a value and is based on the Angular Material input component.
For longer text inputs, also see Textarea
Examples¶
import mesop as me
@me.stateclass
class State:
input: str = ""
def on_blur(e: me.InputBlurEvent):
state = me.state(State)
state.input = e.value
def load(e: me.LoadEvent):
me.set_theme_mode("system")
@me.page(
on_load=load,
security_policy=me.SecurityPolicy(
allowed_iframe_parents=["https://google.github.io"]
),
path="/input",
)
def app():
with me.box(style=me.Style(margin=me.Margin.all(15))):
s = me.state(State)
me.input(label="Basic input", appearance="outline", on_blur=on_blur)
me.text(text=s.input)
API¶
input
¶
Creates a Input component.
PARAMETER | DESCRIPTION |
---|---|
label |
Label for input.
TYPE:
|
on_blur |
blur is fired when the input has lost focus.
TYPE:
|
on_input |
input is fired whenever the input has changed (e.g. user types). Note: this can cause performance issues. Use
TYPE:
|
on_enter |
triggers when the browser detects an "Enter" key on a keyup native browser event.
TYPE:
|
type |
Input type of the element. For textarea, use
TYPE:
|
appearance |
The form field appearance style.
TYPE:
|
style |
Style for input.
TYPE:
|
disabled |
Whether it's disabled.
TYPE:
|
placeholder |
Placeholder value
TYPE:
|
required |
Whether it's required
TYPE:
|
value |
Initial value.
TYPE:
|
readonly |
Whether the element is readonly.
TYPE:
|
hide_required_marker |
Whether the required marker should be hidden.
TYPE:
|
color |
The color palette for the form field.
TYPE:
|
float_label |
Whether the label should always float or float as the user types.
TYPE:
|
subscript_sizing |
Whether the form field should reserve space for one line of hint/error text (default) or to have the spacing grow from 0px as needed based on the size of the hint/error content. Note that when using dynamic sizing, layout shifts will occur when hint/error text changes.
TYPE:
|
hint_label |
Text for the form field hint.
TYPE:
|
key |
The component key.
TYPE:
|
InputBlurEvent
dataclass
¶
Bases: MesopEvent
Represents an inpur blur event (when a user loses focus of an input).
ATTRIBUTE | DESCRIPTION |
---|---|
value |
Input value.
TYPE:
|
key |
key of the component that emitted this event.
TYPE:
|
InputEnterEvent
dataclass
¶
Bases: MesopEvent
Represents an "Enter" keyboard event on an input component.
ATTRIBUTE | DESCRIPTION |
---|---|
value |
Input value.
TYPE:
|
key |
key of the component that emitted this event.
TYPE:
|
InputEvent
dataclass
¶
Bases: MesopEvent
Represents a user input event.
ATTRIBUTE | DESCRIPTION |
---|---|
value |
Input value.
TYPE:
|
key |
key of the component that emitted this event.
TYPE:
|