Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R Shiny Selectize: How to set the minimum number of options in selectizeInput

I am trying to increase the length of the dropdown list when using selectizeInput in Shiny.

I know I can set the max number of items shown by: options = list(maxOptions = n) but how could I define a minimum number of options?

like image 667
Christos Avatar asked Sep 15 '14 08:09

Christos


1 Answers

As said in the comments, there is no minimum number of options setting, at least none that I know of. However, since you're trying to increase the length of the dropdown, you can just do that with CSS.

Suppose this is your dropdown:

  selectizeInput("select", "Select multiple options",
             choices = LETTERS, multiple = T
             ),

Just add:

  tags$style(type='text/css', 
         ".selectize-dropdown-content {
                                       max-height: 600px; ## CHANGE THIS
                                       }"
         ) 

And you get:

                                                               long

As a minimal example, try this:

library(shiny)

ui <- fluidPage(

  selectizeInput("select", "Select multiple options",
                 choices = LETTERS, multiple = T
                 ),
  tags$style(type='text/css', 
             ".selectize-dropdown-content {
                                           max-height: 600px; 
                                           }"
             )   
)

server <- function(input, output){}

shinyApp(ui=ui, server=server)
like image 105
Yang Li Avatar answered Oct 12 '22 22:10

Yang Li