Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multi line text inputs in shiny

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)
like image 916
Rappster Avatar asked Dec 17 '15 09:12

Rappster


1 Answers

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.

like image 152
Ike Avatar answered Oct 22 '22 07:10

Ike