Skip to content

Instantly share code, notes, and snippets.

@jcheng5
Created July 2, 2013 21:25
Show Gist options
  • Save jcheng5/5913297 to your computer and use it in GitHub Desktop.
Save jcheng5/5913297 to your computer and use it in GitHub Desktop.
Bootstrap style help popup for Shiny apps
helpPopup <- function(title, content,
placement=c('right', 'top', 'left', 'bottom'),
trigger=c('click', 'hover', 'focus', 'manual')) {
tagList(
singleton(
tags$head(
tags$script("$(function() { $(\"[data-toggle='popover']\").popover(); })")
)
),
tags$a(
href = "#", class = "btn btn-mini", `data-toggle` = "popover",
title = title, `data-content` = content, `data-animation` = TRUE,
`data-placement` = match.arg(placement, several.ok=TRUE)[1],
`data-trigger` = match.arg(trigger, several.ok=TRUE)[1],
tags$i(class="icon-question-sign")
)
)
}
@dmenne
Copy link

dmenne commented Apr 16, 2014

When content is markdown or html, Umlauts must be given escaped (ü), even if markdown file is UTF-8. Works with Umlauts (äü), when content is given as code string.

@hockeyvic06
Copy link

When using this, the page always pops to the top when the help button is clicked. Any fix to this?

@hassaad85
Copy link

I used to be able to write HTML inside content, but in the new Shiny version HTML is displayed as text. For example,

helpPopup(title = paste0('Choose significance level ', HTML('α')), content = 'something' )

is displayed as "Choose significance level α" (WHERE α is shown as the actual code for alpha, i.e. is SPELLED OUT &ALPHA; )

@cscheeder
Copy link

cscheeder commented Oct 27, 2016

Does anyone have an idea how to use the function when calling it in the server.R inside renderUI and calling it in the ui.R with uiOutput? Thanks

@dvorakt
Copy link

dvorakt commented Jun 23, 2017

I can't get the helpPopup to display HTML either. helpPopup(title=NULL,content=HTML("I like <b>pie</b>.") just displays plain text: I like <b>pie</b>. instead of I like pie.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment