Textarea
Overview
Textarea allows the user to type in a value and is based on the Angular Material input component for <textarea>
.
This is similar to Input, but Textarea is better suited for long text inputs.
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
@me.page(
security_policy=me.SecurityPolicy(
allowed_iframe_parents=["https://google.github.io"]
),
path="/textarea",
)
def app():
s = me.state(State)
me.textarea(label="Basic input", on_blur=on_blur)
me.text(text=s.input)
API
textarea
Creates a Textarea 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:
|
autosize |
If True, the textarea will automatically adjust its height to fit the content, up to the max_rows limit.
TYPE:
|
min_rows |
The minimum number of rows the textarea will display.
TYPE:
|
max_rows |
The maximum number of rows the textarea will display.
TYPE:
|
rows |
The number of lines to show in the text area.
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:
|
native_textarea
Creates a browser native Textarea component. Intended for advanced use cases with maximum UI control.
PARAMETER | DESCRIPTION |
---|---|
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:
|
autosize |
If True, the textarea will automatically adjust its height to fit the content, up to the max_rows limit.
TYPE:
|
min_rows |
The minimum number of rows the textarea will display.
TYPE:
|
max_rows |
The maximum number of rows the textarea will display.
TYPE:
|
style |
Style for input.
TYPE:
|
disabled |
Whether it's disabled.
TYPE:
|
placeholder |
Placeholder value
TYPE:
|
value |
Initial value.
TYPE:
|
readonly |
Whether the element is readonly.
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:
|
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:
|