add_prompt: Add a tooltip for a specific element

View source: R/add_prompt.R

add_promptR Documentation

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
)

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'.

Value

A tooltip when hovering the element concerned.

Examples

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)
}

prompter documentation built on May 29, 2024, 6:34 a.m.