Search code examples
rheadershinydashboardbs4dash

bs4Dash: How to disable (remove) dark/light skin switch?


It seems that changing the main background color and also header (navbar) background color in dark mode is not possible. per this link:

We can always change the sidebar background color in dark (or light using the function for light) mode with this function:

bs4dash_sidebar_dark(
    bg = "", 
),

However, there is no similar function for header.
Therefore, it would be useful to be able to remove or deactivate the dark/light skin switch from the header. I could not find any option to remove this toggle switch. If anyone knows how to do that, it would be highly appreciated.
Here is a simple example code:

library(shiny)
library(bs4Dash)

shinyApp(
  ui = dashboardPage(
    title = "Basic Dashboard",
    header = dashboardHeader(),
    sidebar = dashboardSidebar(),
    controlbar = dashboardControlbar(),
    footer = dashboardFooter(),
    body = dashboardBody()
  ),
  server = function(input, output) {}
)

Example


Solution

  • Set the argument dark = NULL in dashboardPage():

    library(shiny)
    library(bs4Dash)
    
    shinyApp(
      ui = dashboardPage(
        dark = NULL, 
        
        title = "Basic Dashboard",
        header = dashboardHeader(),
        sidebar = dashboardSidebar(),
        controlbar = dashboardControlbar(),
        footer = dashboardFooter(),
        body = dashboardBody()
      ),
      server = function(input, output) {}
    )