popover | R Documentation |
This replaces the shinyBS popover feature that is not compatible with Bootstrap 4
addPopover adds a popover to the given target.
removePopover destroys the current targeted popover.
popover(tag, content, title, placement = c("top", "bottom", "left", "right"))
addPopover(
id = NULL,
selector = NULL,
options,
session = shiny::getDefaultReactiveDomain()
)
removePopover(id, session = shiny::getDefaultReactiveDomain())
tag |
Popover target. |
content |
Popover content. |
title |
Popover title. |
placement |
Popover placement: "top", "bottom", "left" or "right". |
id |
Popover target id. |
selector |
jQuery selector. Allow more customization for the target (nested tags). |
options |
List of options to pass to the popover. See https://getbootstrap.com/docs/4.0/components/popovers/. |
session |
Shiny session object. |
popover does not automatically handles tooltip removal and must be seperately implemented. If the dashboardHeader help parameter is TRUE, all popovers may be enabled or disabled depending on the switch value, which may solve this problem. This allows to toggle popovers whenever required.
This replaces the shinyBS popover feature that is not compatible with Bootstrap 4
if (interactive()) {
library(shiny)
library(bs4Dash)
shinyApp(
ui = dashboardPage(
header = dashboardHeader(),
sidebar = dashboardSidebar(),
controlbar = dashboardControlbar(),
footer = dashboardFooter(),
title = "Popover UI",
body = dashboardBody(
popover(
actionButton("goButton", "Click me to see the popover!"),
title = "My popover",
placement = "right",
content = "Vivamus sagittis lacus vel augue laoreet rutrum faucibus."
)
)
),
server = function(input, output) {}
)
}
if (interactive()) {
library(shiny)
library(bs4Dash)
shinyApp(
ui = dashboardPage(
header = dashboardHeader(),
sidebar = dashboardSidebar(),
controlbar = dashboardControlbar(),
footer = dashboardFooter(),
title = "Popover server",
body = dashboardBody(
sliderInput("obs", "Number of observations:",
min = 0, max = 1000, value = 500
),
plotOutput("distPlot")
)
),
server = function(input, output, session) {
output$distPlot <- renderPlot({
hist(rnorm(input$obs))
})
observeEvent(input$obs, {
if (input$obs > 500) {
addPopover(
id = "distPlot",
options = list(
content = "Vivamus sagittis lacus vel augue laoreet rutrum faucibus.",
title = "Server popover",
placement = "bottom",
trigger = "hover"
)
)
} else {
removePopover(id = "distPlot")
}
})
}
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.