14

What are my options to realize text inputs with multiple lines/line breaks (either explicit or just soft-wraps for nicer output in the UI) in shiny?

I'd like to implement an app that has a description/details field and the content being entered will most likely be more than just one line.

Basically, I'm looking for something to realize a similar functionality of the very text input box of stackoverflow I'm writing this question in: line breaks, scroll bar and/or (auto-)adjustment of height.

Example

# UI ---------------------------------------------------------------------

ui <- fluidPage(
  p(),
  textInput("title", "Title"),
  textInput("description", "Description"),
  tags$hr(),
  h3("Database state"),
  DT::dataTableOutput("datatable")
)

# Server ------------------------------------------------------------------

server <- function(input, output, session) {
  output$datatable <- DT::renderDataTable(
    data.frame(
      Title = input$title,
      Description = input$description,
      stringsAsFactors = FALSE
    )
  )
}

shinyApp(ui, server)
Rappster
  • 12,762
  • 7
  • 71
  • 120
  • 2
    Do you want something like http://stackoverflow.com/questions/14452465/how-to-create-textarea-as-input-in-a-shiny-webapp-in-r ? – Vongo Dec 17 '15 at 09:43
  • @Vongo: that looks promising, thanks for the pointer! "Mutliline input" does in fact describe better what I'm after than "line breaks" – Rappster Dec 17 '15 at 09:51

1 Answers1

15

Try using textAreaInput instead of textInput. With the former you can set height and width, and it automatically will wrap to next line if line is too long.

Here is where it is mentioned in the docs.

Ike
  • 1,039
  • 11
  • 10