Learn R Programming

spsComps (version 0.2)

bsHoverPopover: Bootstrap popover trigger on hover instead of click

Description

enhanced Bootstrap 3 popover by hovering, see bsplus::bs_embed_popover for details. Everything is similar but has additional trigger method, default "hover". Original method only works with "click" on buttons.

Usage

bsHoverPopover(
  tag,
  title = NULL,
  content = NULL,
  placement = "top",
  trigger = "hover",
  ...
)

Arguments

tag

htmltools::tag, generally htmltools::tags$button() or htmltools::tags$a(), or shiny::actionButton()

title

character, title for the popover, generally text

content

character, content for the popover body, can be HTML

placement

character, placement of the popover with respect to tag

trigger

trigger method, default "hover", one of click | hover | focus | manual.

...

other named arguments, passed to bsplus::bs_set_data()

Value

shiny element

Examples

Run this code
# NOT RUN {
if(interactive()){
    library(shiny)
    library(magrittr)
    ui <- fluidPage(
        column(2),
        column(
            8,
            actionButton('a', 'On button') %>%
                bsHoverPopover(
                    title = "title a",
                    content = "popover works on a button",
                    placement = "bottom"
                ),
            tags$a("On link") %>%
                bsHoverPopover(
                    title = "title b",
                    content = "popover works on a link",
                    placement = "bottom"
                ),
            div(
              tags$b("general element"),
              style =
                '
              height: 100px;
              background-color: cornflowerblue;
            '
            ) %>%
              bsHoverPopover(
                title = "general element",
                content = "popover works on a 'div'",
                placement = "right"
              )
        )

    )
    server <- function(input, output, session) {}
    shinyApp(ui, server)
}
# }

Run the code above in your browser using DataLab