rstudio / bslib

Tools for theming Shiny and R Markdown via Bootstrap 3, 4, or 5.
https://rstudio.github.io/bslib/
Other
443 stars 50 forks source link

How to add back dropshadow to card when choosing a theme? #979

Closed ocstringham closed 5 months ago

ocstringham commented 5 months ago

I'm using bootswatch theme "lumen" but now my card() and nav_panel() do not have a dropshadow. Is there a way to add the dropshadow back in?

gadenbuie commented 5 months ago

Hi @ocstringham! You can give your cards the shadow class (or shadow-sm or shadow-lg):

library(shiny)
library(bslib)

ui <- page_navbar(
  title = "Issue 979",
  theme = bs_theme(preset = "lumen"),
  nav_panel(
    "One",
    card("First card", class = "shadow-sm"),
    card("Second card", class = "shadow"),
    card("Third card", class = "shadow-lg")
  )
)

server <- function(...) { }

shinyApp(ui, server)

image

ocstringham commented 5 months ago

Thank you, @gadenbuie. This worked for cards. At the same time, it did not work to give the nav_panel 'card' a shadow. Is there a special way to give nav_panel it's own shadow?

cpsievert commented 5 months ago

You currently have to do that via htmltools::tagAppendAttributes()

page_fixed(
    theme = bs_theme(bootswatch = "lumen"), 
    navset_card_underline(nav_panel("A", "a"), nav_panel("B", "b")) |>
        htmltools::tagAppendAttributes(class = "shadow")
)
ocstringham commented 5 months ago

Worked like a charm. Good to know about htmltools::tagAppendAttributes(), that is useful. Thanks!

github-actions[bot] commented 3 months ago

This issue has been automatically locked. If you have found a related problem, please open a new issue (with a reproducible example or feature request) and link to this issue. :raising_hand: Need help? Connect with us on Discord or Posit Community.