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)
Relevant Functions
-
textAreaInput
textAreaInput(inputId, label, value = "", width = NULL, height = NULL, cols = NULL, rows = NULL, placeholder = NULL, resize = NULL)
Details
Create a field for the user to enter long form text values.
To add a text area to your app:
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.Specify the
inputId
andlabel
parameters oftextAreaInput()
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.Optionally, provide an initial placeholder string to display in the text area with
placeholder
. This string will not be recognized astextAreaInput()
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:
- 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.