Create a bootstrap tooltip

Description

Create bootstrap tooltips for any HTML element to be used in shiny applications.

Usage

1
2
tooltip(refId, text, attr = NULL, animation = TRUE, delay = 100,
  html = TRUE, placement = "auto", trigger = "hover")

Arguments

refId

character (required): id of the element the tooltip is to be attached to.

text

character: Text to be displayed in the tooltip.

attr

character: Attach tooltip to all elements with attribute attr='refId'.

animation

logical: Apply a CSS fade transition to the tooltip.

delay

numeric: Delay showing and hiding the tooltip (ms).

html

logical: Insert HTML into the tooltip.

placement

character: How to position the tooltip - top | bottom | left | right | auto. When 'auto' is specified, it will dynamically reorient the tooltip. For example, if placement is 'auto left', the tooltip will display to the left when possible, otherwise it will display right.

trigger

character: How tooltip is triggered - click | hover | focus | manual. You may pass multiple triggers; separate them with a space.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# javascript code
tt <- tooltip("elementId", "This is a tooltip.")
str(tt)

# example app
## Not run: 
shinyApp(
ui = fluidPage(
  jscolorInput(inputId = "col", label = "JSColor Picker", 
               value = "21BF6B", position = "right", 
               mode = "HVS", close = TRUE),
  tooltip("col", "This is a JScolor widget"),
  
  checkboxInput("cbox", "Checkbox", FALSE),
  tooltip("cbox", "This is a checkbox"),
  
  checkboxGroupInput("cboxg", "Checkbox group", selected = "a", 
                     choices = c("a" = "a",
                                 "b" = "b",
                                 "c" = "c")),
  tooltip("cboxg", "This is a <b>checkbox group</b>", html = TRUE),
  
  selectInput("select", "Selectinput", selected = "a", choices = c("a"="a", "b"="b")),
  tooltip("select", "This is a text input field", attr = "for", placement = "right"),
  
  passwordInput("pwIn", "Passwordinput"),
  tooltip("pwIn", "This is a password input field"),
  
  plotOutput("plot")
),
server = function(input, output) {
  output$plot <- renderPlot({
    plot(cars, col = input$col, cex = 2, pch = 16)
 })
})

## End(Not run)