Can the text within a shiny drop-down be customized to display only part in italics? For example, I would like the Latin names in italics as shown below:
Red Oak - Quercus rubra (11671)
Bur Oak - Quercus macrocarpa (2705)
White Oak - Quercus alba (2437)
library(shiny)
library(tidyverse)
ui <- fluidPage(
tags$head(
tags$style(HTML("
.item {
font-style: italic;
}
.selectize-dropdown-content {
font-style: italic;
}
"))
),
mainPanel(
uiOutput(outputId = "tree"),
# Print selected tree
verbatimTextOutput("selection")
)
)
server <- function(input, output){
my_list <- reactive({
data <- c("Red Oak - Quercus rubra (11671)",
"Bur Oak - Quercus macrocarpa (2705)",
"White Oak - Quercus alba (2437)"
)
my_list <- as.character(data)
})
output$tree <- renderUI({
selectInput(inputId = "tree", label = "Select a Tree", choices = my_list())
})
# Need reactive function to display variable that holds selected tree
output$selection <- renderPrint({
input$tree
})
}
shinyApp(ui = ui, server = server)