shinydashboard icon indicating copy to clipboard operation
shinydashboard copied to clipboard

sidebarUserPanel() background will be override by leafletfix.css:8 when use leaflet package together with shinydashboard.

Open gyang274 opened this issue 9 years ago • 1 comments

I find that leafletfix.css:8 in leaflet overrides shinydashboard css, and makes the sidebarUserPanel() having grey box prominent from the black background. In my opinion, this is unconformable aesthetically. I fixed it by adding style="background-color:transparent;" in div(class = "user-panel", ..., div(class = "pull-left info", ...)) in sidebarUserPanel() source code.

An example of the issue:

## app.R ##
library(shiny)
library(shinydashboard)

library(leaflet)

ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(
    sidebarUserPanel(name = "Ex Machina", subtitle = "Hello World!")
  ),
  dashboardBody(
    leaflet() %>% addTiles()
  )
)

server <- function(input, output) { }

shinyApp(ui, server)

sidebaruserpanel_01 sidebaruserpanel_02 sidebaruserpanel_03

Thank you!

gyang274 avatar Jul 08 '16 19:07 gyang274

Thanks! I'm having the same issue with you! Thanks for sharing

Kbrother1024 avatar Apr 22 '19 20:04 Kbrother1024

Hi I'm facing the same problem. How can I add that div options inside my code?

ShinyFabio avatar Oct 04 '22 09:10 ShinyFabio

Hi I'm facing the same problem. How can I add that div options inside my code?

I would like to know the same thing

IguanMat avatar May 06 '23 16:05 IguanMat

I opened an issue in leaflet, since we should be able to fix this in leaflet's CSS rules. But for now you can add the following line to your dashboardBody() (anywhere you want) to restore the correct user panel styles:

tags$style(HTML(".user-panel > .info { background: unset; }"))

Here's the original app with the fix applied:

## app.R ##
library(shiny)
library(shinydashboard)

library(leaflet)

ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(
    sidebarUserPanel(name = "Ex Machina", subtitle = "Hello World!")
  ),
  dashboardBody(
    leaflet() %>% addTiles(),
    tags$style(HTML(".user-panel > .info { background: unset; }"))
  )
)

server <- function(input, output) { }

shinyApp(ui, server)

Now that we've documented the work-around here, I'm going to close this issue in favor of the leaflet-specific issue. Thanks to @gyang274 for reporting the issue!

gadenbuie avatar May 08 '23 13:05 gadenbuie