删除ShinydashboardPlus中右侧边栏顶部的暗区

时间:2019-12-11 15:57:34

标签: r shinydashboard

当您按下应用程序右上方的图标时,我有一个带有右侧栏的闪亮仪表板。我想删除滑块上方的较暗空间。那可能吗?

enter image description here

library(shiny)
library(shinydashboard)
shinyApp(
  ui = dashboardPagePlus(
    header = dashboardHeaderPlus(
      enable_rightsidebar = TRUE,
      rightSidebarIcon = "gears"
    ),
    sidebar = dashboardSidebar(),
    body = dashboardBody(),
    rightsidebar = rightSidebar(
      background = "dark",

        sliderInput(
          "obs",
          "Number of observations:",
          min = 0, max = 1000, value = 500
        )


    ),
    title = "Right Sidebar"
  ),
  server = function(input, output) { }
)

1 个答案:

答案 0 :(得分:1)

首先,您应该在标题中添加library(shinydashboardPlus),以表明您正在使用该软件包。

您可以选择不使用CSS显示HTML div。如果检查该空白区域上的元素,则会发现其类为“ nav nav-tabs nav-justified control-sidebar-tabs”。

您可以将其添加到标题样式中。例如:

shinyApp(
   ui = dashboardPagePlus(
    tags$head(
      tags$style(
        HTML(
          ".control-sidebar-tabs {display:none;}"
          )
       )
    ),
   header = dashboardHeaderPlus(
   enable_rightsidebar = TRUE,
   rightSidebarIcon = "gears",
   fixed = T
   ),
   sidebar = dashboardSidebar(),
   body = dashboardBody(),
   rightsidebar = rightSidebar(

     sliderInput(
      "obs",
      "Number of observations:",
      min = 0, max = 1000, value = 500
     )

   ),
   title = "Right Sidebar"
 ),
 server = function(input, output) { }
)

理想情况下,您应该将CSS保存在单独的文件中,并将其导入标头中。有关更多信息,请参见here