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)
from shiny import render
from shiny.express import input, ui

(ui.input_text_area("textarea", "Text input", "Hello World"),)  

@render.text
def value():
    return input.textarea()
from shiny import ui, render, App

app_ui = ui.page_fluid(
    ui.input_text_area("textarea", "Text input", "Hello World"),  
    ui.output_text_verbatim("value"),
)

def server(input, output, session):
    @render.text
    def value():
        return input.textarea()

app = App(app_ui, server)
No matching items

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)

No matching items

Details

Create a textarea input control for entry of unstructured text values.

To add a textarea to your app:

  1. 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.

  2. Specify the id and label parameters of ui.input_text_area() to define the identifier and label of the textarea.

  3. By default, the value parameter, which defines the textarea’s initial value, is the empty string (''). Provide a different string to value 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:

  1. 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