rstudio / rstudio/gt

GT, interactive or not, tables not displaying correctly header (if present) if used with tabset

Open
#2,139 0 comments 0 reactions 1 assignee View on GitHub

@rich-iannone is already working on this.

Since Apr 20, 2026.

Type: ☹︎ Bug
Dominant language
R
Stars
2.2k
Forks
225
Avg merge
1d 19h
Merged PRs (30d)
11

Description

Prework

Description

Adding gt tables with interactive options in quarto and tabsets results in errors in the header sections.
The <div class> is not parsed correctly.

Reproducible example

---
title: "Gt interactive or not tables not correctly displaying if header in tabset"
format: html
engine: knitr
---

```{r}
#| label: libs-import
library(gt)
library(tidyverse)
library(quartabs)
```

```{r}
#| include: false
#| label: blank-allows-gt-to-work
gt::gt(mtcars) |>
  gt::opt_interactive()
```


```{r}
#| results: asis
#| label: display-tabs-nointeractive
mtcars |>
    nest_by(cyl) |>
    rowwise() |>
    mutate(
        cyl_gt = list(
            gt(data) |>
                tab_header(
                    title = "Title",
                    subtitle = "Subtitle"
                )
        )
    ) |>
    quartabs::render_tabset(cyl, cyl_gt)
```

```{r}
#| results: asis
#| label: display-tabs-interactive
mtcars |>
    nest_by(cyl) |>
    rowwise() |>
    mutate(
        cyl_gt = list(
            gt(data) |>
                opt_interactive() |>
                tab_header(
                    title = "Title",
                    subtitle = "Subtitle"
                )
        )
    ) |>
    quartabs::render_tabset(cyl, cyl_gt)
```

I'm using package quartabs for this. It's a wrapper for including figs and tables in tabset in quarto.
I've tried the classic hacks from here or here.

If there is no header defined by tab_header(), it's working.

With GT interactive tables, if I had a header with the function, I get at the beginning of each tab:

<div class="gt_heading gt_title gt_font_normal" style="text-size:bigger;">Title</div>
<div class="gt_heading gt_subtitle ">Subtitle</div>

instead of the header correctly displayed with the correct style.

In addition, if the GT tables are not interactive, the header is displayed but without the formatting (tab_style for example)

```{r}
#| include: false
#| label: blank-allows-gt-to-work
gt::gt(mtcars) |>
  gt::opt_interactive()
```

is recommended by the vignette of quartabs here to resolve javascript dependencies.

Looking at the HTML output, it seems I can see why I get with behaviour

<pre><code>&lt;div class="gt_heading gt_title gt_font_normal" style="text-size:bigger;"&gt;Title&lt;/div&gt;
&lt;div class="gt_heading gt_subtitle "&gt;Subtitle&lt;/div&gt;</code></pre>

The formatting of the HTML seems wrong.

Expected result

Each tab should have a GT table with correct header if filled.

  • Not interactive: header with the style (color, alignment, ...)
  • Interactive: the header in HTML should be correct

Working code without loop:


:::{.panel-tabset}

## 4

```{r}
#| results: asis
#| label: panel-4
gt(mtcars |>
    filter(cyl == 4)) |>
    opt_interactive()  |>
    tab_header(
        title = "Title",
        subtitle = "Subtitle"
        )
```

## 6

```{r}
#| results: asis
#| label: panel-6
gt(mtcars |>
    filter(cyl == 6)) |>
    opt_interactive() |>
    tab_header(
        title = "Title",
        subtitle = "Subtitle"
        )
```

## 8

```{r}
#| results: asis
#| label: panel-8
gt(mtcars |>
    filter(cyl == 8)) |>
    opt_interactive() |>
    tab_header(
        title = "Title",
        subtitle = "Subtitle"
        )

```

:::

Session info

R version 4.5.3 (2026-03-11)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 24.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so;  LAPACK version 3.12.0

locale:
 [1] LC_CTYPE=fr_FR.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=fr_FR.UTF-8        LC_COLLATE=fr_FR.UTF-8    
 [5] LC_MONETARY=fr_FR.UTF-8    LC_MESSAGES=fr_FR.UTF-8   
 [7] LC_PAPER=fr_FR.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C       

time zone: Europe/Paris
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
 [1] quartabs_0.1.1  lubridate_1.9.5 forcats_1.0.1   stringr_1.6.0  
 [5] dplyr_1.2.1     purrr_1.2.2     readr_2.2.0     tidyr_1.3.2    
 [9] tibble_3.3.1    ggplot2_4.0.2   tidyverse_2.0.0 gt_1.3.0       

loaded via a namespace (and not attached):
 [1] sass_0.4.10        generics_0.1.4     bspm_0.5.7         xml2_1.5.2        
 [5] stringi_1.8.7      hms_1.1.4          digest_0.6.39      magrittr_2.0.5    
 [9] evaluate_1.0.5     grid_4.5.3         timechange_0.4.0   RColorBrewer_1.1-3
[13] fastmap_1.2.0      jsonlite_2.0.0     crosstalk_1.2.2    scales_1.4.0      
[17] cli_3.6.6          rlang_1.2.0        reactR_0.6.1       withr_3.0.2       
[21] yaml_2.3.12        otel_0.2.0         tools_4.5.3        tzdb_0.5.0        
[25] vctrs_0.7.3        R6_2.6.1           lifecycle_1.0.5    reactable_0.4.5   
[29] fs_2.0.1           htmlwidgets_1.6.4  pkgconfig_2.0.3    pillar_1.11.1     
[33] gtable_0.3.6       glue_1.8.0         xfun_0.57          tidyselect_1.2.1  
[37] knitr_1.51         dichromat_2.0-0.1  farver_2.1.2       htmltools_0.5.9   
[41] rmarkdown_2.31     compiler_4.5.3     S7_0.2.1  

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.