简体   繁体   中英

Remove the dark space at the top of the right sidebar in a shinydashboardPlus

I have a shinydashboard with a rightsidebar enabled when you press the icon on top right of the app. I would like to remove this darker space above the slider. Is that possible?

在此处输入图片说明

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) { }
)

Firstly, you should add library(shinydashboardPlus) to your header to indicate you're using that package.

You could opt to not display that HTML div using css. If you inspect element on that blank space, you'll find its class is "nav nav-tabs nav-justified control-sidebar-tabs".

You could add that to your header style. For example:

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) { }
)

Ideally, you should keep your css in a separate file, and import it in your header. See here for more info.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM