| input_submit_textarea | R Documentation |
Creates a textarea input where users can enter multi-line text and submit their input using a dedicated button or keyboard shortcut. This control is ideal when you want to capture finalized input, rather than reacting to every keystroke, making it useful for chat boxes, comments, or other scenarios where users may compose and review their text before submitting.
input_submit_textarea(
id,
label = NULL,
...,
placeholder = NULL,
value = "",
width = "min(680px, 100%)",
rows = 1,
button = NULL,
toolbar = NULL,
submit_key = c("enter+modifier", "enter")
)
update_submit_textarea(
id,
...,
value = NULL,
placeholder = NULL,
label = NULL,
submit = FALSE,
focus = FALSE,
session = get_current_session()
)
id |
The input ID. |
label |
The label to display above the input control. If |
... |
Additional attributes to apply to the underlying |
placeholder |
The placeholder text for the user input. |
value |
The value to set the user input to. |
width |
Any valid CSS unit (e.g., |
rows |
The number of rows (i.e., height) of the textarea. This essentially sets the minimum height – the textarea can grow taller as the user enters more text. |
button |
A htmltools::tags element to use for the submit button. It's recommended
that this be a |
toolbar |
A list of optional UI elements (e.g., links, icons) to display next to the submit button. |
submit_key |
A character string indicating what keyboard event should
trigger the submit button. The default is |
submit |
Whether to automatically submit the text for the user. Requires |
focus |
Whether to move focus to the input element. Requires |
session |
The |
A textarea input control that can be added to a UI definition.
The server receives a character string containing the user's text input.
Important: The initial server value is always "" (empty string),
regardless of any value parameter provided to input_submit_textarea().
The server value updates only when the user explicitly submits the input by
either pressing the Enter key (possibly with a modifier key) or clicking the
submit button.
update_submit_textarea(), input_task_button()
library(shiny)
library(bslib)
ui <- page_fluid(
input_submit_textarea("text", placeholder = "Enter some input..."),
verbatimTextOutput("value")
)
server <- function(input, output) {
output$value <- renderText({
req(input$text)
Sys.sleep(2)
paste("You entered:", input$text)
})
}
shinyApp(ui, server)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.