Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 653
Sirshendu Maiti Avatar asked Oct 18 '25 04:10

Sirshendu Maiti


2 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.

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

like image 155
Ike Avatar answered Oct 20 '25 19:10

Ike


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)
like image 22
Eduardo Bergel Avatar answered Oct 20 '25 20:10

Eduardo Bergel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!