bsPopover: Enhanced Bootstrap3 popover

Description Usage Arguments Details Value Examples

View source: R/popover_tip.R

Description

Add popover to any Shiny element you want. You can also customize color, font size, background color, and more for each individual popover.

Usage

 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
38
39
40
41
42
43
44
45
46
47
48
bsPopover(
  tag,
  title = "",
  content = "",
  placement = "top",
  bgcolor = "#ebebeb",
  titlecolor = "black",
  contentcolor = "black",
  titlesize = "14px",
  contentsize = "12px",
  titleweight = "600",
  contentweight = "400",
  opacity = 1,
  html = FALSE,
  trigger = "hover focus"
)

bsHoverPopover(
  tag,
  title = "",
  content = "",
  placement = "top",
  bgcolor = "#ebebeb",
  titlecolor = "black",
  contentcolor = "black",
  titlesize = "14px",
  contentsize = "12px",
  titleweight = "600",
  contentweight = "400",
  opacity = 1,
  html = FALSE,
  trigger = "hover focus"
)

bsPop(
  tag,
  title = "",
  content = "",
  placement = "top",
  status = "primary",
  titlesize = "14px",
  contentsize = "12px",
  titleweight = "600",
  contentweight = "400",
  opacity = 1,
  html = TRUE,
  trigger = "hover focus"
)

Arguments

tag

a shiny tag as input

title

string, popover title

content

string, popover cotent

placement

string, one of "top", "bottom", "left", "right", where to put the tooltip

bgcolor

string, background color, valid value of CSS color name or hex value or rgb value

titlecolor

string, title text color, valid value of CSS color name or hex value or rgb value

contentcolor

string, content text color, valid value of CSS color name or hex value or rgb value

titlesize

string, title text font size, valid value of CSS font size, like "10px", "1rem".

contentsize

string, content text font size, valid value of CSS font size, like "10px", "1rem".

titleweight

string, CSS valid title font weight unit

contentweight

string, CSS valid content font weight unit

opacity

numeric, between 0 and 1

html

bool, allow title contain HTML code? like "<strong>abc</strong>"

trigger

string, how to trigger the tooltip, one or combination of click | hover | focus | manual.

status

string, used only for wrapper bsPop, see details

Details

  1. For trigger methods read: https://getbootstrap.com/docs/3.3/javascript/#tooltips-options.

  2. For font weight, see: https://www.w3schools.com/cssref/pr_font_weight.asp

  3. bsHoverPopover is the old name but we still keep it for backward compatibility.

Convenient wrapper function

bsPop is the convenient function for bsPopover, which has the background and content color set to 5 different bootstrap colors, you can use status to set, one of "primary", "info", "success", "warning", "danger"

Value

shiny tag

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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
if(interactive()){
  library(shiny)
  library(magrittr)
  ui <- fluidPage(
    br(), br(), br(), br(), br(), br(), column(2),
    actionButton("", "Popover on the left") %>%
      bsPopover("Popover on the left", "content", "left"),
    actionButton("", "Popover on the top") %>%
      bsPopover("Popover on the top", "content", "top"),
    actionButton("", "Popover on the right") %>%
      bsPopover("Popover on the right", "content", "right"),
    actionButton("", "Popover on the bottom") %>%
      bsPopover("Popover on the bottom", "content", "bottom"),
    br(), br(), column(2),
    actionButton("", "primary color") %>%
      bsPopover(
        "primary color", "content", bgcolor = "#0275d8",
        titlecolor = "white", contentcolor = "#0275d8"),
    actionButton("", "danger color") %>%
      bsPopover(
        "danger color",  "content", bgcolor = "#d9534f",
        titlecolor = "white", contentcolor = "#d9534f"),
    actionButton("", "warning color") %>%
      bsPopover(
        "warning color", "content", bgcolor = "#f0ad4e",
        titlecolor = "white", contentcolor = "#f0ad4e"),
    br(), br(), column(2),
    actionButton("", "9px & 14px") %>%
      bsPopover("9px", "14", titlesize = "9px", contentsize = ),
    actionButton("", "14px & 12px") %>%
      bsPopover("14px", "12", titlesize = "14px"),
    actionButton("", "20px & 9px") %>%
      bsPopover("20px", "9", titlesize = "20px"),
    br(), br(), column(2),
    actionButton("", "weight 100 & 800") %>%
      bsPopover("weight 100", "800", titleweight =  "100", contentweight = "800"),
    actionButton("", "weight 400 & 600") %>%
      bsPopover("weight 400", "600", titleweight =  "400", contentweight = "600"),
    actionButton("", "weight 600 & 400") %>%
      bsPopover("weight 600", "400", titleweight =  "600", contentweight = "400"),
    actionButton("", "weight 900 & 200") %>%
      bsPopover("weight 900", "200", titleweight =  "900", contentweight = "200"),
    br(), br(), column(2),
    actionButton("", "opacity 0.2") %>%
      bsPopover("opacity 0.2", opacity = 0.2),
    actionButton("", "opacity 0.5") %>%
      bsPopover("opacity 0.5", opacity = 0.5),
    actionButton("", "opacity 0.8") %>%
      bsPopover("opacity 0.8", opacity = 0.8),
    actionButton("", "opacity 1") %>%
      bsPopover("opacity 1", opacity = 1),
    br(), br(), column(2),
    actionButton("f1", "allow html: 'abc<span class='text-danger'>danger</span>'") %>%
      bsPopover(HTML("abc<span class='text-danger'>danger</span>"),
                html = TRUE, bgcolor = "#0275d8"),
    actionButton("f2", "allow html: '<s>del content</s>'") %>%
      bsPopover(HTML("<s>del content</s>"), html = TRUE, bgcolor = "#d9534f")
  )
  server <- function(input, output, session) {}
  shinyApp(ui, server)
}
if(interactive()){
  library(shiny)
  library(magrittr)
  ui <- fluidPage(
    br(), br(), br(), br(), br(), br(), column(2),
    actionButton("", "primary") %>%
      bsPop("primary", "primary", status = "primary"),
    actionButton("", "info") %>%
      bsPop("info", "info", status = "info"),
    actionButton("", "success") %>%
      bsPop("success", "success", status = "success"),
    actionButton("", "warning") %>%
      bsPop("warning", "warning", status = "warning"),
    actionButton("", "danger") %>%
      bsPop("danger", "danger", status = "danger")
  )
  server <- function(input, output, session) {}
  shinyApp(ui, server)
}

spsComps documentation built on Feb. 3, 2022, 1:07 a.m.