Increase with of selectizeInput() text box

1,642 views
Skip to first unread message

Matt Brigida

unread,
May 15, 2015, 12:33:36 PM5/15/15
to shiny-...@googlegroups.com
I have sentences in a selectizeInput box.  I would like to widen the box so the lines are not wrapped.   I have used the 'width' option in the selectizeInput function, however it will only increase the size a bit.  If I, say, increase it from 'width = 500px' to 'width = 1000px'  nothing happens.


by setting 

inputPanel(                                                                                          
     tags$head(                                                                                       
        tags$style(type="text/css", "label.radio { display: inline-block; }", ".radio input[type=\"radio\"] { float: none; }"),                                                                             
        tags$style(type="text/css", "select { max-width: 1000px; }"),                                 
        tags$style(type="text/css", "textarea { max-width: 1000px; }"),                               
        tags$style(type="text/css", ".jslider { max-width: 1000px; }"),                               
        tags$style(type='text/css', ".well { max-width: 1000px; }"),                                  
        tags$style(type='text/css', ".span4 { max-width: 1000px; }")                                  
      ),                                                                                              
            selectizeInput( ...., width = 1000px)

but it doesn't widen the box.  The only change is the box is set in the middle of the input panel.

Any suggestions on how to widen the box?


Joe DeWitt

unread,
May 15, 2015, 2:22:10 PM5/15/15
to shiny-...@googlegroups.com
The width parameter refers to the col span using the bootstrap layout. It's a 12 column system, so 12 is full width, 6 is half width, etc. The actual width in pixels depends on the parent container.

Yihui Xie

unread,
May 19, 2015, 5:02:33 PM5/19/15
to Joe DeWitt, shiny-discuss, Matt Brigida
To Joe: For functions like column() in shiny, `width` means the col
span in Bootstrap. For the case of selectizeInput(), `width` is the
normal CSS width.

To Matt: could you provide a minimal reproducible example along with
your sessionInfo()? I just tested it and it seems to work well:

library(shiny)
shinyApp(
ui = fluidPage(
selectizeInput('foo', 'Foo', choices = letters, width = '1000px')
),
server = function(input, output, session) {
}
)

Regards,
Yihui

Matt Brigida

unread,
May 19, 2015, 6:01:46 PM5/19/15
to shiny-...@googlegroups.com, mdbr...@gmail.com, joejd...@gmail.com
Yihui,

Thanks for your reply.  It is a shiny app in a R markdown presentation.  A reproducible example and session info are below:

Matt


---                                                                                                                    
title: "Reproducible Example"                                                                                          
author: "Matt Brigida"                                                                                                 
date: "05/20/2015"                                                                                                     
output: ioslides_presentation                                                                                          
runtime: shiny                                                                                                         
smaller: true                                                                                                          
---                                                                                                                    
                                                                                                                       
## R Markdown Slide                                                                                                    
                                                                                                                       
```{r, warning=FALSE, echo=FALSE, message=FALSE}                                                                       
 inputPanel(                                                                                                           
            selectizeInput("phrase", "Message",                                                                        
                 choices = list(                                                                                       
                 "The message received. Hopefully viewed in a wide text box." = "Return this message.",                
                 "Another message received." = "Return this.")                                                         
                 , width = '1000px')                                                                                   
     )                                                                                                                 
renderPlot({                                                                                                           
plot(c(0,0), type = 'n', ylab = "", xlab = "", xaxt = "n", yaxt = "n")                                                 
text(1.5, 0, input$phrase, cex = 2)                                                                                    
})                                                                                                                                                                                                                        
```         

> sessionInfo()
R version 3.2.0 (2015-04-16)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux stretch/sid

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] vimcom_1.1-0   setwidth_1.0-3 colorout_1.1-0

loaded via a namespace (and not attached):
[1] tools_3.2.0

Yihui Xie

unread,
May 19, 2015, 6:13:20 PM5/19/15
to Matt Brigida, shiny-discuss, Winston Chang
Thanks. I can reproduce it. The problem came from this line in
shiny.css: https://github.com/rstudio/shiny/blob/8f893a9752c/inst/www/shared/shiny.css#L174
which came from this commit
https://github.com/rstudio/shiny/commit/c3e5b4fa36b89 Winston, any
thoughts?

Regards,
Yihui

Winston Chang

unread,
May 19, 2015, 6:26:34 PM5/19/15
to Yihui Xie, Matt Brigida, shiny-discuss
Adding this to the top of your document (after the header block) should do the trick:

<style>
.shiny-flow-layout>div {
  width: 100%;
}
</style>

Matt Brigida

unread,
May 19, 2015, 6:41:40 PM5/19/15
to shiny-...@googlegroups.com, mdbr...@gmail.com, yi...@rstudio.com
Works perfectly.  Thanks Winston & Yihui.

Matt
Reply all
Reply to author
Forward
0 new messages