Search code examples
colorsshinytabpanel

How can I change the color of tabPanel title on the server side?


In Shiny, on the UI side my code is:

mainPanel(uiOutput('my_tabsetpanel'))

and on the Server side I have:

output$my_tabsetpanel <- renderUI({
    tabPanel(mytabtitle, DT::dataTableOutput(id))
})

How can I change only the color of the tab title?


Solution

  • You could wrap the title in a div and change the style.

    Here is an example:

    library(shiny)
    
    ui <- fluidPage(
            mainPanel(uiOutput('my_tabsetpanel'))
    )
    
    server <- function(input, output) {
        output$my_tabsetpanel <- renderUI({
            tabsetPanel(tabPanel(div("mytabtitle", style = "color: red;"), "my content"))
        })
    }
    
    shinyApp(ui = ui, server = server)
    

    Result:

    enter image description here