Title: | Add Tooltips to 'R markdown' Documents or 'Shiny' Apps |
---|---|
Description: | 'Htmlwidget' of 'Tippyjs' to add tooltips to 'Shiny' apps and 'R markdown' documents. |
Authors: | John Coene [aut, cre] |
Maintainer: | John Coene <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.0 |
Built: | 2024-11-03 02:48:58 UTC |
Source: | https://github.com/johncoene/tippy |
__Deprecated.__ Dynamically use tippy.
use_tippy() tippy_class(class, ...) with_tippy(element, tooltip, ...)
use_tippy() tippy_class(class, ...) with_tippy(element, tooltip, ...)
class |
Class of elements to apply tooltip to. |
... |
Any option from the official documentation. |
element |
Shiny, or htmltools element, or character string. |
tooltip |
Content of tooltip. |
use_tippy
Includes tippy.js in header.
call_tippy
call tippy
on specific target element(s), place after elements to be targeted.
library(shiny) if(FALSE){ shinyApp( ui = fluidPage( p("Some text", class = "tooltip"), p("Some text", class = "tooltip"), p("Some text", class = "tooltip"), p("Some text", class = "tooltip"), p("Some text", class = "tooltip"), p("Some text", class = "tooltip"), tippy("tooltip", content = "Hi!") # all elements with class ), server = function(input, output) {} ) }
library(shiny) if(FALSE){ shinyApp( ui = fluidPage( p("Some text", class = "tooltip"), p("Some text", class = "tooltip"), p("Some text", class = "tooltip"), p("Some text", class = "tooltip"), p("Some text", class = "tooltip"), p("Some text", class = "tooltip"), tippy("tooltip", content = "Hi!") # all elements with class ), server = function(input, output) {} ) }
Call tippy methods on tooltips.
tippy_disable( selectors = NULL, .session = shiny::getDefaultReactiveDomain(), .is_tag = FALSE ) tippy_enable( selectors = NULL, .session = shiny::getDefaultReactiveDomain(), .is_tag = FALSE ) tippy_destroy( selectors = NULL, .session = shiny::getDefaultReactiveDomain(), .is_tag = FALSE ) tippy_show( selectors = NULL, .session = shiny::getDefaultReactiveDomain(), .is_tag = FALSE ) tippy_hide( selectors = NULL, .session = shiny::getDefaultReactiveDomain(), .is_tag = FALSE )
tippy_disable( selectors = NULL, .session = shiny::getDefaultReactiveDomain(), .is_tag = FALSE ) tippy_enable( selectors = NULL, .session = shiny::getDefaultReactiveDomain(), .is_tag = FALSE ) tippy_destroy( selectors = NULL, .session = shiny::getDefaultReactiveDomain(), .is_tag = FALSE ) tippy_show( selectors = NULL, .session = shiny::getDefaultReactiveDomain(), .is_tag = FALSE ) tippy_hide( selectors = NULL, .session = shiny::getDefaultReactiveDomain(), .is_tag = FALSE )
selectors |
Selectors of tooltips to apply the method. If 'NULL' then the method is applied to _all tooltips._ |
.session |
A valid shiny session. |
.is_tag |
Whether 'selectors' are tags, e.g.: '<p>'. |
library(shiny) library(tippy) ui <- fluidPage( useTippy(), h5("plot tooltip", class = "tip"), p("Another tooltip", class = "tip"), tippyThis( ".tip", "This is indeed a tooltip" ), actionButton("disable", "Disable"), actionButton("enable", "Enable") ) server <- function(input, output) { observeEvent(input$disable, { tippy_disable() }); observeEvent(input$enable, { tippy_enable() }) } if(FALSE) { shinyApp(ui, server) }
library(shiny) library(tippy) ui <- fluidPage( useTippy(), h5("plot tooltip", class = "tip"), p("Another tooltip", class = "tip"), tippyThis( ".tip", "This is indeed a tooltip" ), actionButton("disable", "Disable"), actionButton("enable", "Enable") ) server <- function(input, output) { observeEvent(input$disable, { tippy_disable() }); observeEvent(input$enable, { tippy_enable() }) } if(FALSE) { shinyApp(ui, server) }
Add tooltips to an element.
tippy(element, content, ...)
tippy(element, content, ...)
element |
Shiny, or htmltools element, or character string. |
content |
Content of the tooltip. |
... |
Any other options from the official documentation. |
if(FALSE){ tippy("Hover me!", content = "Hi, I'm the tooltip!") tippy(h3("Hello"), content = "World") }
if(FALSE){ tippy("Hover me!", content = "Hi, I'm the tooltip!") tippy(h3("Hello"), content = "World") }
Set a global theme. Every tooltip will subsequently use this theme.
tippy_global_theme(name)
tippy_global_theme(name)
name |
Name of the theme to set. |
Use a plot as tooltip
tippy_plot( selector, plotId, ..., .width = 200, .height = 200, .hidePlot = FALSE, .session = shiny::getDefaultReactiveDomain() )
tippy_plot( selector, plotId, ..., .width = 200, .height = 200, .hidePlot = FALSE, .session = shiny::getDefaultReactiveDomain() )
selector |
A CSS selector, e.g.: '#id' or '.class'. If it is a bare selector (e.g.: 'sth') then it is assumed to be an id and processed as '#sth'. Set '.is_tag' to 'TRUE' to disable that. |
plotId |
Id of plot to use. |
... |
Any other options from the official documentation. |
.width , .height
|
Dimensions of plot. |
.hidePlot |
Whether to hide the original plot. |
.session |
A valid shiny session. |
library(shiny) ui <- fluidPage( useTippy(), plotOutput("plot"), h5("plot tooltip", id = "plotTip") ) server <- function(input, output) { output$plot <- renderPlot({ on.exit({ tippy_plot( "plotTip", "plot", theme = "light", .hidePlot = TRUE, .width = 600, .height = 200, maxWidth = 700 ) }) plot(cars) }) } if(FALSE){ shinyApp(ui, server) }
library(shiny) ui <- fluidPage( useTippy(), plotOutput("plot"), h5("plot tooltip", id = "plotTip") ) server <- function(input, output) { output$plot <- renderPlot({ on.exit({ tippy_plot( "plotTip", "plot", theme = "light", .hidePlot = TRUE, .width = 600, .height = 200, maxWidth = 700 ) }) plot(cars) }) } if(FALSE){ shinyApp(ui, server) }
Binds a tooltip to a valid CSS selector.
tippy_this(selector, content = NULL, ...) tippyThis(selector, content = NULL, ..., .is_tag = FALSE)
tippy_this(selector, content = NULL, ...) tippyThis(selector, content = NULL, ..., .is_tag = FALSE)
selector |
A CSS selector, e.g.: '#id' or '.class'. If it is a bare selector (e.g.: 'sth') then it is assumed to be an id and processed as '#sth'. Set '.is_tag' to 'TRUE' to disable that. |
content |
Content of the tooltip. |
... |
Any other options from the official documentation. |
.is_tag |
Whether the selector is a tag, e.g.: '<p>'. |
library(shiny) ui <- fluidPage( tippy(h3("Hello"), "World"), h4("World", id = "theId"), tippyThis("theId", "A tooltip") ) server <- function(input, output) {} if(FALSE){ shinyApp(ui, server) }
library(shiny) ui <- fluidPage( tippy(h3("Hello"), "World"), h4("World", id = "theId"), tippyThis("theId", "A tooltip") ) server <- function(input, output) {} if(FALSE){ shinyApp(ui, server) }
Set tippy defaults that will be shared by all other tooltips.
tippyDefault(...)
tippyDefault(...)
... |
Any other options from the official documentation. |
Convenience function to create a theme.
tippyTheme( name, box_bg = "black", box_color = "white", box_font_size = "12px", arrow_color = box_bg, content_bg = box_bg, content_color = box_color, content_font_size = box_font_size )
tippyTheme( name, box_bg = "black", box_color = "white", box_font_size = "12px", arrow_color = box_bg, content_bg = box_bg, content_color = box_color, content_font_size = box_font_size )
name |
Name of theme. |
box_bg , box_color , content_bg , content_color
|
Background and text color respectively. |
box_font_size , content_font_size
|
Size of the font. |
arrow_color |
Color of the arrow (if enabled). |
library(shiny) ui <- fluidPage( useTippy(), tippyTheme("myTheme", box_bg = "darkred"), h5("plot tooltip", id = "plotTip"), tippyThis( "plotTip", "Hello world", theme = "myTheme" ) ) server <- function(input, output) {} if(FALSE){ shinyApp(ui, server) }
library(shiny) ui <- fluidPage( useTippy(), tippyTheme("myTheme", box_bg = "darkred"), h5("plot tooltip", id = "plotTip"), tippyThis( "plotTip", "Hello world", theme = "myTheme" ) ) server <- function(input, output) {} if(FALSE){ shinyApp(ui, server) }
Include dependencies, place anywhere in the shiny UI.
useTippy()
useTippy()