Open shahreyar-abeer opened 2 years ago
It'll be very similar for cells, but you'll have to use a cell render function instead. For example:
library(htmltools)
library(dplyr)
library(tippy)
data <- as_tibble(mtcars[1:6, ], rownames = "car") %>%
select(car:hp)
# See the ?tippy documentation to learn how to customize tooltips
with_tooltip <- function(value, tooltip, ...) {
div(style = "text-decoration: underline; text-decoration-style: dotted; cursor: help",
tippy(value, tooltip, ...))
}
reactable(
data,
columns = list(
mpg = colDef(cell = function(value) with_tooltip(value, "Miles per US gallon")),
cyl = colDef(cell = function(value) with_tooltip(value, "Number of cylinders"))
)
)
An equivalent but more straightforward way of writing this would be something like:
reactable(
data,
columns = list(
mpg = colDef(
cell = function(value) {
div(style = "text-decoration: underline; text-decoration-style: dotted; cursor: help",
tippy(value, "tooltip text"))
}
)
)
)
Is there a way to make the tooltip dynamic, depending on other cell values? For example "${mpg} Miles per gallon and ${cyl} number of cylinders" instead of "tooltip text"
Hi there,
On the documentation, there is an example to use
tippy
with the headers.I'm looking to use it in the cells instead. How should I do that? Mainly having trouble passing the
element
arg totippy::tippy