shinyWidgets::updatePickerInput , change an option of the picker input on the client side

Hi everyone,

I would like to know if it's possible to change on the client side one or more options (e.g : maxOptions, title, actionsBox, ...) from a specific pickerInput with updatePickerInput ?
Since there is no "options" argument in this function, I guess the answer is "No"...

If so, does anyone have any ideas to do this on the client side ? Any clue is welcome :slight_smile:

Thanks very much,


Not sure what are exactly you are trying to achieve, but maybe render the input again instead of updating it? Assign the new rendered picker to the same variable name as the original input.

Hi Peter,

Thanks for the reply.
Yep, it sounds good and indeed it will work...
But, in the context of my app, something that I don't want to see happen if continue in such way.
If you have time to spend, could you please check out this minimal case test ?
I tried to explain as clear as possible what I want to achieve.
English is not my mother tongue so I hope it will not be too messy.
Lastly, one cannot upload txt file in R community post thus ui.R and server.R are c/p below :

Many thanks,

(If somtehing wrong with this test app, feel free to contact me).



  ui = fluidPage(
  titlePanel("Minimal test case"),
                  selectInput(inputId = "choice",
                              label = "Make a choice",
                              choices = list("Choice_1" = "c1", "Choice_2" = "c2"), selected = "c1"),

                  conditionalPanel(condition = "input.tabset1 == 'Tab1' | input.tabset1 == 'Tab2'",
                  conditionalPanel(condition = "input.tabset1 == 'Tab3'",

           tabsetPanel(id = "tabset1",
                       tabPanel("Main tab 1", value = "Tab1",
                       tabPanel("Main tab 2", value = "Tab2",
                       tabPanel("Secondary tab", value = "Tab3",



server = function(input, output, session){
   output$textinfo <- renderText({

  output$input1 <- renderUI({
    # if (input$tabset1 == "Tab1" | input$tabset1 == "Tab2") {
    #   opt.pickerinput <- list(
    #   `actions-box` = TRUE,
    #   `deselect-all-text` = "Deselect all",
    #   `select-all-text` = "Select all",
    #   `none-selected-text` = "Make a choice",
    #   `live-search` = TRUE,
    #   `multiple-separator` = " | "
    #   ) } else {
    #     opt.pickerinput <- list(
    #       `max-options` = 1,
    #       `max-options-text` = "Only one choice!",
    #       `none-selected-text` = "Make a choice")
    #   }
    # pickerInput("input1", "Picker input 1", choices = as.character(c(1:5)) , multiple = TRUE, options = opt.pickerinput)
    pickerInput("input1", "Picker input 1", choices = as.character(c(1:5)) , multiple = TRUE, options = list(
      `actions-box` = TRUE,
      `deselect-all-text` = "Deselect all",
      `select-all-text` = "Select all",
      `none-selected-text` = "Make a choice",
      `live-search` = TRUE,
      `multiple-separator` = " | "

  output$input1_bis <- renderUI({
    if(input$tabset1 == "Tab3") {
    pickerInput("input1_bis", "Picker input 1 for Secondary tab", choices = as.character(c(1:5)) , multiple = TRUE, options = list(
      `max-options` = 1,
      `max-options-text` = "Only one choice!",
      `none-selected-text` = "Make a choice"))
    } else {

output$text_tab1 <- renderText({
  "I have nothing to say :-) Input 1 works. 
Please select something and then switch to Main tab 2"
output$text_tab2 <- renderText({
"Normally, Picker input 1 would have been flushed since input1 is reevaluated on server side. Indeed there is an if() statement in the renderUI(input1).
In the context of this app, this is an issue since I want to keep available user's choices made in Main tab 1.
As one can see, to avoid this phenomenon, I had no choice to set up another renderUI(picker Input) for the Secondary tab. Therefore, there's no if() statement in input1 (check commented code) anymore. 
In this way, input1 won't be reevaluated and user's choices remain visible in Main tab 2:-)
I hope that these changes (i.e. other options in pikcerInput) could be done more straightforward with shinyWidget::updatePickerInput on client side
Example : 
observeEvent(input$tabset1, {
  if (input$tabset1 == Tab3) {
  updatePickerInput(session, inputId = input1, selected = , options = list(
 max-options = 1,
 max-options-text = Only one choice!,
 none-selected-text = Make a choice))
This would avoid the need to create another pickerinput on server side for this kind of app" 

output$text_tab3 <- renderText({
  "For this tab, it's not a big deal if Picker input 1 is flushed..." 


This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.