In this challenge, we aim to enhance the appearance of a Shiny application using tabsetPanels. We aim to create a UI where the selected panel features a white text on a black background, while the inactive tabs maintain a white background with black text.
Below is the code used to illustrate the solution:
library(shiny) ui <- shinyUI( fluidPage( tags$style(".nav-tabs { background-color: #006747; } .nav-tabs-custom .nav-tabs li.active:hover a, .nav-tabs-custom .nav-tabs li.active a { background-color: transparent; border-color: transparent; } .nav-tabs-custom .nav-tabs li.active { border-top-color: #FFF; }"), tabsetPanel( tabPanel( title = "Hello", textInput(inputId = "text", label = "Input") ), tabPanel( title = "World" ) ) ) ) server <- shinyServer(function(input, output, session){ }) shinyApp(ui=ui, server=server)
The solution provides a visually appealing application where the active tab is highlighted with a black background and white text. The inactive tabs remain easily distinguishable with their white background and black text.
As Shiny CSS changes are prone to occur over time, it's important to adapt the code accordingly. However, the core principles outlined in this solution should continue to guide the customization process.
The above is the detailed content of How to Customize Tab Colors in Shiny\'s tabPanel?. For more information, please follow other related articles on the PHP Chinese website!