Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to make a flextable html output hoverable?

I am trying to mimic hoverablity effect like tables produced with kableExtra which creates a very appealing effect and was wondering if anyone has an idea how this may be doable with flextable.

Here's an example Rmd to get a glimpse of what I mean. I'd like the flextable to allow the hover effect that is visible in the kable.

---
output: bookdown::html_document2
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```

```{r mykable}
iris |>
  head() |>
  kableExtra::kbl(caption = "a caption") |>
  kableExtra::kable_styling(bootstrap_options = "hover")
```

```{r myflextable}
iris |>
  head() |>
  flextable::flextable() |>
  flextable::set_caption("a caption")
```
like image 378
Patrick Avatar asked Sep 14 '25 12:09

Patrick


1 Answers

Use flextable::set_table_properties to add custom CSS.

flextable::set_table_properties(opts_html = list(
    extra_css = "
      tbody tr:hover {
        background-color: #f5f5f5 !important;
        transition: background-color 0.3s ease;
      }
    "
  ))
like image 125
M-- Avatar answered Sep 17 '25 00:09

M--