Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Additional margin-top applied to popovers and accordions #375

Closed
markschat opened this issue Oct 6, 2021 · 3 comments · Fixed by #396
Closed

Additional margin-top applied to popovers and accordions #375

markschat opened this issue Oct 6, 2021 · 3 comments · Fixed by #396
Milestone

Comments

@markschat
Copy link

I tried to use the popover component of bootstrap 5 and recognized, that the styles are off:

image

The default margin (h3 -> 1.5em) is applied to the popovers-heading causing an ugly whitespace obove the heading. This is not the intended bootstrap styling, instead the margin should be reset to 0 by the styles provided in _reboot.scss. At least that is what I see when inspecting the popover element contained in the bootstrap-docs.

As I am only able to see the minified css version from my shiny app I can´t figure out the exact reason why this happens. It seems to me that the styles are loaded in an unexpected order so that the default h3-style overrides the popover-styles (at least the margin-reset from _reboot.scss).

Reproducible Code Example:

library(shiny)
library(bslib)
library(htmltools)

init_popover <- "$(window).on('load', function(){$('[data-bs-toggle=\"popover\"]').popover({html: true})});"

ui <- fluidPage(
  theme = bslib::bs_theme(5),
  
  # initiate popover ----
  tags$head(tags$script(init_popover)),
  
  # use popover ----
  tags$button(
    type = "button", 
    class = "btn btn-primary m-5", 
    "data-bs-toggle" = "popover", 
    title = "Popover-Title", 
    "data-bs-content" = "Popover-Content",
    "Button"
  )
)
server <- function(input, output, session) {}

shinyApp(ui, server)
@cpsievert
Copy link
Collaborator

Thanks for the report! For a temporary workaround, you can do:

bslib::bs_theme(5) %>%
    bslib::bs_add_rules(".popover-header { margin-top: 0}")

For posterity, I believe this is also a problem for accordions with h2.accordion-header, as used in the examples https://getbootstrap.com/docs/5.0/components/accordion/

@cpsievert cpsievert changed the title Wrong css styles applied on bootstrap 5 popovers Additional margin-top applied to popovers and accordions Oct 6, 2021
@cpsievert cpsievert added this to the CRAN 0.4.0 milestone Oct 21, 2021
@mubashirqasim
Copy link

Excellent library but a little bit hard to implement some of the components like popovers, tooltips and modals. I wonder if it is possible to add some handy functions such as:

library(bsplus)
bs_button("A button") %>%
  bs_embed_popover(title = "I'm a popover", content = "Really!")

@github-actions
Copy link

This issue has been automatically locked. If you believe you have found a related problem, please open a new issue (with a reproducible example or feature request) and link to this issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 19, 2023
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants