Search code examples
rshinyshiny-server

How to add bigger textInput box in R Shiny?


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!


Solution

  • 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)