2

pickerInput from shinyWidgets package has a placeholder title Nothing selected.

How is it possible to replace it with Pick a choice for example ? I would prefer a solution that uses css or the options of pickerInput, if possible avoid shinyjs.

library(shiny)
library(shinyWidgets)

ui <- fluidPage(

  tags$head(
    tags$style(HTML("

    "))
  ),

  pickerInput(
    inputId = "mtcInputIndicateur", 
    label = "Select values", 
    choices = paste("choice", 1:10),
    options = list(`live-search` = TRUE),
    multiple = TRUE
  )
)



server <- function(input, output){
}

shinyApp(ui, server)

Any help would be greatly appreciated.

Clemsang
  • 5,053
  • 3
  • 23
  • 41

1 Answers1

3

Just found the answer, use the parameter title in options.

library(shiny)
library(shinyWidgets)

ui <- fluidPage(

  pickerInput(
    inputId = "mtcInputIndicateur", 
    label = "Select values", 
    choices = paste("choice", 1:10),
    options = list(`live-search` = TRUE, title = "Pick a choice"),
    multiple = TRUE
  )
)



server <- function(input, output){
}

shinyApp(ui, server)
Clemsang
  • 5,053
  • 3
  • 23
  • 41
  • Does this solution not work with `updatePickerInput`? I am trying to change the placeholder when user clicks the search button by using `observeEvent`, but this doesn't seem to work on my end.. – Howard Baek Sep 14 '22 at 08:56
  • I think you should place `pickerInput` inside `renderUI` function in `server` with a `uiOutput` in `ui` – Clemsang Sep 19 '22 at 06:46