Text Area

#| standalone: true
#| components: [viewer]
#| viewerHeight: 200

library(shiny)
library(bslib)

ui <- page_fluid(
  textAreaInput( 
    "text", 
    "Text input", 
    value = "Hello World"
  ), 
  verbatimTextOutput("value")
)

server <- function(input, output) {
  output$value <- renderText({input$text})
}

shinyApp(ui = ui, server = server)
library(shiny)
library(bslib)

ui <- page_fluid(
  textAreaInput( 
    "text", 
    "Text input", 
    value = "Hello World"
  ), 
  verbatimTextOutput("value")
)

server <- function(input, output) {
  output$value <- renderText({input$text})
}

shinyApp(ui = ui, server = server)
No matching items

Relevant Functions

  • textAreaInput
    textAreaInput(inputId, label, value = "", width = NULL, height = NULL, cols = NULL, rows = NULL, placeholder = NULL, resize = NULL)

No matching items

Details

Create a field for the user to enter long form text values.

To add a text area to your app:

  1. Add textAreaInput() 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 inputId and label parameters of textAreaInput() 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.

  4. Optionally, provide an initial placeholder string to display in the text area with placeholder. This string will not be recognized as textAreaInput() will not treat this placeholder as a value.

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: