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

1

10

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?

Gaulin answered 15/9, 2014 at 8:22 Comment(4)
Instead of minimum number of options, I think you might be asking the minimal height of the selectize input?Camenae
My target is to increase the size of the dropdown list. I believe that this would be achieved if I could either increase the minimal height of the selectize input (as you suggest) or if I could define a minimum number of options.Gaulin
There is no minimum number of options in selectize input: it just shows all available options, subject to the constraint of maxOptions. I guess you might be able to change its height using CSS. I have not tried, though.Camenae
Did you ever resolve the issue about setting the minimum number of options?Kunz
I
4

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)
Ingratitude answered 7/2, 2017 at 1:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.