I am trying to modify a search bar in Shiny
such as we can type either the content or his header in pickerInput
.
Code example :
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
pickerInput(
inputId = "pick", label = "Selected",
choices = split(c("Choice 1" = "Value 1", "Choice 2" = "Value 2"), c("First", "Other")),
multiple = TRUE,
options = list( `live-search` = TRUE)
)
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
This way is would like to type text Choice 2
or Other
in search bar and get the second input. But research on Other
gives no result.
An answer that hide the header but can search on it might be accepted.
Any help would be greatly appreciated.
If you install development version of {shinyWidgets} (v0.4.9.940, soon on CRAN), you can pass a slot tokens
in choicesOpt
to declare some keywords used in live search :
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
pickerInput(
inputId = "pick", label = "Selected",
choices = split(c("Choice 1" = "Value 1", "Choice 2" = "Value 2"), c("First", "Other")),
multiple = TRUE,
options = list( `live-search` = TRUE),
choicesOpt = list(
tokens = c("first choice 1", "other choice 2")
)
)
)
server <- function(input, output, session) {
}
shinyApp(ui, server)