I want my Shiny select input to:
- Has no label
- Has customized background colour:
#2f2d57
- Has placeholder
- Enable users to type-in and select
However, I can't make the app follow the above 4 rules together. My codes are below:
Data:
table <- data.frame(col1 = c(3, 4, 8, 5, 2, 6, 7))
Attempt 1
Problem: Users are unable to type-in and select from the selectInput
ui <- fluidPage(
uiOutput("container")
)
server <- function(input, output) {
output$container <- renderUI({
fluidRow(
tags$style("#three_code_zip_selector {color: #ffffff; background-color: #2f2d57;}"),
selectInput('three_code_zip_selector', NULL, choices = c("Please Select Desired Number" = "", table$col1), selectize = F)
)
})
}
shinyApp(ui = ui, server = server)
Attempt 2
Problem: By deleting selectize = F
, users can type-in to select, but the background colour is not changed.
ui <- fluidPage(
uiOutput("container")
)
server <- function(input, output) {
output$container <- renderUI({
fluidRow(
tags$style("#three_code_zip_selector {color: #ffffff; background-color: #2f2d57;}"),
selectInput('three_code_zip_selector', NULL, choices = c("Please Select Desired Number" = "", table$col1))
)
})
}
shinyApp(ui = ui, server = server)
I was also trying selectizeInput
, but seems like it still has the same problem as above.
Attempt 3
Problem: Users can to type in, but the background colour is not changed, and there's a label at the top of selectizeInput which I don't want.
ui <- fluidPage(
uiOutput("container")
)
server <- function(input, output) {
output$container <- renderUI({
fluidRow(
tags$style(".selectize-dropdown-content .active {background: #2f2d57; !important;color: #ffffff; !important;}"),
selectizeInput('three_code_zip_selector', "s", choices = c("Please Select Desired Number" = "", table$col1))
)
})
}
shinyApp(ui = ui, server = server)
Does anyone have ideas on how could I be able to satisfy all the 4 rules? Thanks in advance!
".selectize-dropdown-content"
? Sometimes changing minute details of a shiny widget can change its html callsign as well. – Chabo