Text Area
#| standalone: true
#| components: [viewer]
#| viewerHeight: 200
## file: app.py
from shiny import ui, render, App
app_ui = ui.page_fluid(
ui.input_text_area("textarea", "", "Hello World").add_class(
"pt-5 mx-auto text-center"
),
ui.output_text_verbatim("value"),
{"class": "vh-100 justify-content-center align-items-center px-5"},
).add_class("my-auto text-center")
def server(input, output, session):
@render.text
def value():
return input.textarea()
app = App(app_ui, server)
Relevant Functions
-
ui.input_text_area
ui.input_text_area(id, label, value='', *, width=None, height=None, cols=None, rows=None, placeholder=None, resize=None, autoresize=False, autocomplete=None, spellcheck=None)
Details
Create a textarea input control for entry of unstructured text values.
To add a textarea to your app:
Add
ui.input_text_area()
to the UI of your app to create a textarea. Where you call this function will determine where the textarea will appear within the app’s layout.Specify the
id
andlabel
parameters ofui.input_text_area()
to define the identifier and label of the textarea.By default, the
value
parameter, which defines the textarea’s initial value, is the empty string (''
). Provide a different string tovalue
to change the initial text.
The value of an input component is accessible as a reactive value within the server()
function. To access the value of a textarea:
- Use
input.<textarea_id>()
(e.g.,input.textarea()
) to access the value of the textarea. The server value of a textarea is a string containing the current text input.
See also: Text Box