TextAreaInput#
Download this notebook from GitHub (right-click to download).
import panel as pn
import panel_material_ui as pmui
pn.extension()
The TextAreaInput
allows entering any multiline string using a text input box. Lines are joined with the newline character \n
. Unfortunately in the notebook, enter keys may not be intercepted correctly (see ipywidgets).
Discover more on using widgets to add interactivity to your applications in the how-to guides on interactivity. Alternatively, learn how to set up callbacks and (JS-)links between parameters or how to use them as part of declarative UIs with Param.
Parameters:#
For details on other options for customizing the component see the customization guides.
Core#
disabled
(boolean, default=False): Whether the widget is editablevalue
(str): The current value updated when the widget loses focus because the user clicks away or presses the tab key.value_input
(str): The current value updated on every key press.
Display#
auto_grow
(boolean, default=False): Whether the TextArea should automatically grow in height to fit the content.color
(str): A color variant'default'
(white),'primary'
(blue),'success'
(green),'info'
(yellow),'light'
(light), or'danger'
(red).cols
(int, default=2): The number of columns in the text input field.max_length
(int, default=5000): Max character length of the input field. Defaults to 5000max_rows
(int, default=None): The maximum number of rows in the text input field whenauto_grow=True
.label
(str): The title of the widgetplaceholder
(str): A placeholder string displayed when no value is enteredrows
(int, default=2): The number of rows in the text input field.resizable
(boolean | str, default=’both’): Whether the layout is interactively resizable, and if so in which dimensions:width
,height
, orboth
.variant
(Literal["filled", "outlined", "standard"]
): The variant of the input field.
Styling#
sx
(dict): Component level styling API.theme_config
(dict): Theming API.
Aliases#
For compatibility with Panel certain parameters are allowed as aliases:
button_style
: Alias forvariant
button_type
: Alias forcolor
name
: Alias forlabel
text_area_input = pmui.TextAreaInput(name='Text Area Input', placeholder='Enter a string here...')
text_area_input
TextAreaInput.value
returns a string type that can be read out and set like other widgets:
text_area_input.value
An auto-growing TextAreaInput
will grow (and shrink) in height to accommodate the entered text. Setting rows
together with auto_grow
will set a lower bound on the number of rows and setting max_rows
will provide an upper bound:
pmui.TextAreaInput(name='Growing TextArea', auto_grow=True, max_rows=10, rows=6, value="""\
This text area will grow when newlines are added to the text:
1. Foo
2. Bar
3. Baz
""", width=500)
If you only want the text area to be resizable in the vertical direction, you can set the resizeable parameter to ‘height’:
pmui.TextAreaInput(name="Vertical Adjustable TextArea", resizable="height")
Controls#
The TextAreaInput
widget exposes a number of options which can be changed from both Python and Javascript. Try out the effect of these parameters interactively:
pn.Row(text_area_input.controls(jslink=True), text_area_input)
Download this notebook from GitHub (right-click to download).