popover: Popovers

View source: R/popover.R

popoverR Documentation

Popovers

Description

Popovers are small windows of content associated with a tag element. Use popover() to construct the element and showPopover() to add it to any tag element with an HTML id. Popovers are great for explaining inputs and giving hints to the users. Popovers are hidden with closePopover().

Usage

popover(..., title = NULL)

showPopover(
  id,
  popover,
  placement = "top",
  duration = NULL,
  session = getDefaultReactiveDomain()
)

closePopover(id, session = getDefaultReactiveDomain())

Arguments

...

Character strings or tag elements specifying the content of the popover or additional named arguments passed as HTML attributes to the parent element.

title

A character string specifying a title for the popover, defaults to NULL, in which case a title is not added.

id

A character string specifying the id of a popover's target tag element.

popover

The popover element to show, typically a call to popover().

placement

One of "top", "left", "bottom", or "right" specifying where the popover is positioned relative to the target tag element indicated by id, defaults to "top".

duration

A positive integer specifying the duration of the popover in seconds or NULL, in which case the popover is not automatically removed. When NULL the popover must be removed with closePopover().

session

A reactive context, defaults to getDefaultReactiveDomain().

Example application

ui <- container(
  buttonInput("showHelp", "Help!"),
  div(
    id = "textBlock1",
    "Sociis natoque penatibus et magnis"
  ) %>%
    padding(3)
) %>%
  display("flex") %>%
  flex(justify = "around")

server <- function(input, output) {
  observeEvent(input$showHelp, ignoreInit = TRUE, {
    showPopover(
      target = "textBlock1",
      popover(title = "Hint", "I am a <div> element!"),
      placement = "bottom",
      duration = 4
    )
  })
}

shinyApp(ui, server)

See Also

Other components: alert(), badge(), blockquote(), card(), collapsePane(), d1(), dropdown(), img(), jumbotron(), modal(), navContent(), pre(), toast()

Examples


### Examples

# Please see example application above.


nteetor/yonder documentation built on June 8, 2022, 1:36 p.m.