Is there a way of changing the text color of a tab in shiny conditional on another tab being active? I know how to change the text color of the selected tab, but I want to also change the color of another specific tab at the same time.
For example, in the minimal example below, I would like to highlight both Tabs 2 and 3 labels in red whenever Tab 2 is selected:
# ui
ui <- navbarPage(
id = "navbar",
tags$style(HTML(".tabbable > .nav > li > a {color:blue}
.tabbable > .nav > li[class=active] > a {color:red}")),
tabsetPanel(id="tabs",
tabPanel(value = "tab1", title= "Tab1"),
tabPanel(value = "tab2", title= "Tab2"),
tabPanel(value = "tab3", title= "Tab3")
)
)
# server
server <- function(input, output, session) {
}
shinyApp(ui, server)
I imagine this is easily achieved, but I’m a CSS beginner. Any help would be much appreciated!
2
Answers
Not sure I understand your question, but if I understand it this is what you want:
The easiest (and fastest) way to do this is with a bit of JavaScript