Learn R Programming

prompter (version 1.2.0)

add_prompt: Add a tooltip for a specific element

Description

Add a tooltip for a specific element

Usage

add_prompt(
  ui_element,
  position = "bottom",
  message = NULL,
  type = NULL,
  size = NULL,
  permanent = FALSE,
  rounded = FALSE,
  animate = TRUE,
  bounce = FALSE,
  arrow = TRUE,
  shadow = TRUE
)

Value

A tooltip when hovering the element concerned.

Arguments

ui_element

Element on which a tooltip will be added.

position

Position of the tooltip. Can be `bottom`, `bottom-left`, `bottom-right`, `left`, `right`, `top`, `top-left`, `top-right`. Default is `bottom`.

message

Message to include in the tooltip. This argument is mandatory.

type

Type of the tooltip. Can be `NULL` (default), `error`, `warning`, `info`, `success`.

size

Size of the tooltip. Can be `NULL` (default), `small`, `medium`, `large`.

permanent

Boolean indicating whether the tooltip should be visible permanently (or at the contrary only when hovering the element). Default is `FALSE`.

rounded

Boolean indicating whether the corners of the tooltip should be rounded. Default is `FALSE`.

animate

Boolean indicating whether there is a small animation when the tooltip appears. Default is `TRUE`.

bounce

Boolean indicating whether there is a small boucing animation when the tooltip appears. Default is `FALSE`.

arrow

Boolean indicating whether there is an arrow on the tooltip. Default is `TRUE`.

shadow

Boolean indicating whether there should be a shadow effect. Default is `TRUE`.

Examples

Run this code
if (interactive()) {
library(shiny)

ui <- fluidPage(

  use_prompt(),

  add_prompt(
    tableOutput("table"),
    position = "bottom", type = "warning",
    message = "this is a table", permanent = FALSE,
    rounded = TRUE, animate = FALSE
  )

  # also works with magrittr's pipe
  # tableOutput("table") %>%
  #   add_prompt(
  #     position = "bottom", type = "warning",
  #     message = "this is a button", permanent = FALSE,
  #     rounded = TRUE, animate = FALSE
  #   )
)

server <- function(input, output, session) {

  output$table <- renderTable(head(mtcars))

}

shinyApp(ui, server)
}

Run the code above in your browser using DataLab