Home > database >  How to change the color of the label of inactive tabs in shiny
How to change the color of the label of inactive tabs in shiny

Time:02-03

Here is an example of an app with 3 tabs:

library(shiny)


ui <- fluidPage(
  tags$head(
    tags$style(HTML("
      .tabset .nav-tabs .nav-link:not(.active) {
        color: purple;
      }
    "))
  ),
  tabsetPanel(
    tabPanel("Tab 1",
             h1("This is Tab 1")
    ),
    tabPanel("Tab 2",
             h1("This is Tab 2")
    ),
    tabPanel("Tab 3",
             h1("This is Tab 3")
    )
  )
)


server <- function(input, output) {
}


shinyApp(ui, server)

By default the inactive tabs have their labels with a blue font. I need them to be purple

I see no arguments that allow me to change this default behaviour

CodePudding user response:

library(shiny)

ui <- fluidPage(
  tags$head(
    tags$style(HTML("
     .tabbable > .nav > li > a                  {color:purple}
     .tabbable > .nav > li[class=active]    > a {color:black}
    "))
  ),
  tabsetPanel(
    tabPanel("Tab 1",
             h1("This is Tab 1")
    ),
    tabPanel("Tab 2",
             h1("This is Tab 2")
    ),
    tabPanel("Tab 3",
             h1("This is Tab 3")
    )
  )
)


server <- function(input, output) {
}


shinyApp(ui, server)
  • Related