无法正确更改 bs4Dash::dashboardSidebar() 的背景颜色

Not able to change the background color of the bs4Dash::dashboardSidebar() properly

1.仅使用 bs4Dash

的颜色问题

我开始使用包 bs4Dash,我遇到了左侧边栏背景颜色的问题 bs4Dash::dashboardSidebar()。我观察到,当我启动应用程序时,左侧边栏的背景颜色始终为灰色,但是当我切换到深色模式并返回浅色模式时,颜色呈现为白色背景。

您可以使用以下摘自 bs4Dash

help webpage 的代码来观察此行为
library(shiny)
library(bs4Dash)

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

2。使用 freshbs4Dash package

的颜色问题

使用包fresh 第一次打开app还是灰底色,但是当我从暗模式切换到亮模式时渲染了颜色根据 fresh::create_theme().

这是一个例子

# library

library(shiny)
library(bs4Dash)
library(fresh)

# theme creator with fresh::

mytheme <- create_theme(
    bs4dash_sidebar_light(
        bg = "#FFFF00")
)

#shinyApp

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

我在 Github 中发现了 this 问题,但不知道如何解决这个问题。

this issue 中提到了这个问题。您可以通过在dashboardSidebar()中添加skin = "light"来修复它,如下所示:

library(shiny)
library(bs4Dash)

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