Search code examples
htmlrr-markdown

Show text in a box when hovering over word


I would like to show a definition of a word in a R markdown file when hovering over a word.

For a link it can be done like this: [I'm an inline-style link with title](https://www.google.com "Google's Homepage") Upon hovering over I'm an inline-style link with title the text Google's Homepage will pop up. However, I would like to do the same for a word and give the definition of the word in a box without the link.

Something like: [word]("Definition of word that pops up in a box upon hovering"). Is this possible?


Solution

  • One option is the tippy package.

    ```{r setup, include=FALSE}
    knitr::opts_chunk$set(echo = TRUE)
    library(tippy)
    ```
    
    This is a 
    ```{r echo = FALSE}
    tippy("word.", tooltip = "Definition of word that pops up in a box upon hovering")
    ```
    I would like to know its definition.
    

    enter image description here