4

I am creating a Shiny App, where in one part I need the user to input a text summary, but the default size of text input box appearing in the App is very small. difficult for users to enter a summary of 3-4 lines. Could you help me with the script that can make the text input box bigger. really appreciate your help!

Snapshot from my App

=========== I just tried the following with HTML tags:

library(shiny)

shinyUI(fluidPage(
  sidebarLayout(
    sidebarPanel(
      tags$textarea(id="my_textarea", rows=5, "Leave a comment...")
    ),
    mainPanel(
      uiOutput("my_output")
    )
  )
))

but got some error - shown below!

alistaire
  • 42,459
  • 4
  • 77
  • 117
  • I am trying the following but each time getting the following error in my Shiny App. "ERROR: $ operator is invalid for atomic vectors" shinyUI(fluidPage( sidebarLayout( sidebarPanel( tags$textarea(id="my_textarea", rows=5, "Leave a comment...") ), mainPanel( uiOutput("my_output") ) ) )) – Sirshendu Maiti Aug 21 '16 at 00:00
  • It works for me as-is. The only `$` shown is `tags$textarea`, which should exist if you've loaded shiny (and haven't defined another variable called `tags`). – alistaire Aug 21 '16 at 00:32

2 Answers2

7

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.

This seems to be a duplicate of this question; Multi line text inputs in shiny

Community
  • 1
  • 1
Ike
  • 1,039
  • 11
  • 10
2

I made a small aesthetic change(css to 100%), but it does work as it is. The error might be from some other section of your code. See the example below.

library(shiny)

ui<-shinyUI(fluidPage(
  sidebarLayout(
    sidebarPanel( 
           tags$style(type="text/css", "textarea {width:100%}") ,
           tags$textarea(id="my_textarea", rows=5,placeholder =  "Leave a comment...", "") 
    ) 
    ,mainPanel( h4('My panel') )
  )
))

server <- shinyServer(function(input, output) {}) 

shinyApp(ui, server)
Tonio Liebrand
  • 17,189
  • 4
  • 39
  • 59
Eduardo Bergel
  • 2,685
  • 1
  • 16
  • 21
  • Thanks a lot @Ron Talbot ... it worked after adding "shiny::tags" – Sirshendu Maiti Aug 21 '16 at 19:36
  • `shinyUI(fluidPage( sidebarLayout( sidebarPanel( shiny::tags$style(type="text/css", "textarea {width:100%}") , shiny::tags$textarea(id="my_textarea", rows=5,placeholder = "Leave a comment...", value="") ) ,mainPanel( h4('My panel') ) ) ))` – Sirshendu Maiti Aug 21 '16 at 19:36
  • had to remove "value" argument for the text to be displayed,...good answer anyway! – Tonio Liebrand Dec 29 '18 at 11:27